Bib*_*bix 7 android android-layout android-drawable
是否可以制作由多个图像/比例/对齐组成的xml背景?因此,有一个复杂的drawable xml可用作android布局的背景.
例如,这是我想要做的动态xml背景:

因此,对于我的所有不同活动,请将上面的不同布局/视图放在上面:

我知道我不能将布局设置为layout_background,但这里是我想要做的设计(根据之前的图片):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_image" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/main_image" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/footer_image" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我看到我们可以将位图设置为可绘制的xml,但是对于缩放和对齐?有没有更简单的方法来进行这种视觉渲染?
Chi*_*tel 10
您可以根据需要创建一个布局, dynamic xml background并且可以像这样包含在所有屏幕中RelativeLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background="@color/app_bg"
android:gravity="center_horizontal">
<include layout="@layout/my_dynamic_layout"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
...Your layout code ...
</RelativeLayout >
</RelativeLayout >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4330 次 |
| 最近记录: |