答案 0 :(得分:2)
在这个我使用表格布局来达到你的要求.....在src你把你的图像放在drawable ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="150dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#c8c8c8" />
</RelativeLayout>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/TextView04"
android:layout_weight="1"
android:background="#dcdcdc"
android:gravity="center"
android:padding="20dip"
android:text="Row 2 column 1"
android:textColor="#000000"
android:src="@drawable/swara"/>
<ImageView
android:id="@+id/TextView04"
android:layout_weight="1"
android:background="#d3d3d3"
android:gravity="center"
android:padding="20dip"
android:text="Row 2 column 2"
android:textColor="#000000"
android:src="@drawable/swara"/> </TableRow>
答案 1 :(得分:1)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/upper_linear_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:background="@android:color/white"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="horizontal"
android:id="@+id/colourlayout"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:orientation="horizontal"
android:background="@color/colorAccent"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:id="@+id/image1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:orientation="horizontal"
android:background="@color/colorPrimary"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:id="@+id/image2"
/>
</LinearLayout>
</LinearLayout></LinearLayout>
答案 2 :(得分:0)
这可能会有所帮助。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<!-- Your code goes here -->
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/img_1"
android:onclick="callFucntion1" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/img_2"
android:onclick="callFucntion2" />
</LinearLayout>
</LinearLayout>
答案 3 :(得分:0)
我想这就是你想要的。将图像放在相应的图像布局元素中。
android:src="........"
代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="200"
android:layout_above="@+id/colourlayout"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:id="@+id/colourlayout"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:background="@color/colorAccent"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:id="@+id/image1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:background="@color/colorPrimary"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:id="@+id/image2"
/>
</LinearLayout>
</LinearLayout></RelativeLayout>
对于可点击的操作,您需要通过在java文件中调用findviewbyID来获取图像的引用。
示例:
ImageView image1 = (ImageView) findViewbyID(R.id.image1);
image1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//code what should happen after clicking the image
}
});
希望这有帮助。