我想创建一个覆盖2个布局的按钮。 我正在使用线性布局并为其添加适当的重量。 附上了一个屏幕截图供参考。
这是我的XML tag.xml:
<?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:gravity="center"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:background="@color/greyColor"
android:gravity="center" >
<ImageView
android:id="@+id/ximgvwCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/camera_big" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="70"
android:background="@android:color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:padding="5dp"
android:text="@string/strQ1"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textColor="@android:color/darker_gray" />
</LinearLayout>
</ScrollView>
请帮帮我。 提前谢谢!
答案 0 :(得分:6)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp" >
<ImageView
android:id="@+id/imageCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/image_top" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:background="@drawable/image_bottom"
android:layout_height="match_parent" >
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageProfile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="end"
android:layout_marginTop="100dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
查看此类
答案 1 :(得分:0)
您需要相对布局。将图像对齐设置为右上角并适当设置边距顶部。
答案 2 :(得分:0)
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/first"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:src="@drawable/firstImage" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:src="@drawable/middleImage" >
</ImageView>
<RelativeLayout
android:id="@+id/second"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="@id/first"
android:src="@drawable/share_over" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/YES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/YES" />
<ImageView
android:id="@+id/NO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/NO" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
将图像分为TOP-MIDDLE-BOTTOM(布局)。你的尺寸看起来像上面但是 你可以改变宽度/高度尺寸。