Android 如何使ImageView“匹配父对象”?
如何使底部图像和白色框填充视图的整个宽度?我试着把它拖过来和你的父母配对,但还是没有成功。图像的底角应位于视图的底角。但它的高度必须保持不变 这是我到目前为止所拥有的XMLAndroid 如何使ImageView“匹配父对象”?,android,xml,android-layout,layout,Android,Xml,Android Layout,Layout,如何使底部图像和白色框填充视图的整个宽度?我试着把它拖过来和你的父母配对,但还是没有成功。图像的底角应位于视图的底角。但它的高度必须保持不变 这是我到目前为止所拥有的XML <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" an
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/landscape"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="80dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_gallery_button" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/home_gallery_button" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_gallery_button" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_gallery_button" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_gallery_button" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_gallery_button" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="117dp"
android:layout_marginTop="0dp"
android:src="@drawable/home_tralee_header_image" />
</LinearLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:src="@drawable/infromationpage_alliance_banner" />
</RelativeLayout>
还有,有没有办法在XML中调整图像的大小?当我尝试调整大小时,例如,通过拖动顶部的角,图像不会随着布局调整大小。这是否意味着我必须将图像缩小?要使每张图像的大小精确,似乎需要做很多工作。有没有一种方法可以用XML或java编程实现这一点?试试看
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
主要亲戚的
但是,您将需要添加
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
你想在每一行添加填充物,或者将它们全部放在自己的布局中,只需在其中添加填充物即可。尝试使用填充物
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
主要亲戚的
但是,您将需要添加
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
对于每一行,您都希望有填充,或者将它们全部放在自己的布局中,只需将填充添加到其中即可