hiii ...我能够显示图像网址中的图像,实际上图像网址存储在数组字符串中,我使用
显示图像URL aURL = new URL(imagePath);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
imageLoader.setImageBitmap(bm);
imageLoader.setImageBitmap(bm);
现在我想添加两个按钮,左边和右边的图像意味着图像将在两个按钮之间....我的main.xml是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/imageLoader"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:text="Button" android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button android:text="Button" android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
如何做到这一点我急切地等待回应......感谢所有的回应......
答案 0 :(得分:0)
您应该使用RelativeLayout
来实现此目标,例如:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:id="@+id/back" android:text="Back"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<Button android:id="@+id/next" android:text="Next"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<ImageView android:id="@+id/imageLoader"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_toLeftOf="@id/next"
android:layout_toRightOf="@id/back" />
</RelativeLayout>
让Buttons
在视图中垂直居中,因此它们会在包装图像的左侧和右侧进行操作,您应该将其声明中的android:layout_alignParentTop="true"
更改为{{1} }:
android:layout_centerVertical="true"
答案 1 :(得分:0)
尝试水平方向的布局应该足够好。机器人:取向= “垂直” &GT;而是使用水平。同时将布局顺序更改为按钮,图像,按钮。
答案 2 :(得分:0)
试试这个......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/imageLoader"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:text="Button" android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:android:layout_toLeftOf="@+id/imageLoader"
android:layout_marginTop="30dip">
</Button>
<Button android:text="Button" android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageLoader"
android:layout_marginTop="30dip">
</Button>
根据您的要求调整最高值...希望它有助于您...