大佬教程收集整理的这篇文章主要介绍了右侧带有视图的Android布局,占据预设空间,左侧视图可以将屏幕的其余部分填充到一定的限制,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
奇怪的是,如果我希望右侧的视图是扩展的视图,并且左侧的视图是占用预设空间的视图,这将非常容易.如果您将每个视图设置为所需的宽度(在水平线性布局中),如果两个视图都不适合,Android将自动缩小左侧的视图.
我想在一个布局文件中执行此操作;这种布局已经设计用于sw512dp-land和sw765dp-land之间的显示.
如果我能找到一种方法让Android缩小左侧的布局(当布局都不能适合指定的大小时),下面的代码就可以工作了.但默认情况下,系统会先缩小右侧的布局.
<LinearLayout xmlns:android="http://scheR_434_11845@as.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <RelativeLayout android:id="@+id/left" android:layout_width="150dip" android:layout_height="fill_parent" android:BACkground="@color/red" > </RelativeLayout> <LinearLayout android:id="@+id/right" android:layout_width="100dip" android:layout_height="fill_parent" android:layout_alignParentright="true" android:layout_alignParentTop="true" android:BACkground="@color/green" > </LinearLayout>
如果我不需要左边的布局来停止某个点的扩展,那么这个代码(来自@Lokesh)就可以工作了.
<RelativeLayout xmlns:android="http://scheR_434_11845@as.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <LinearLayout android:id="@+id/left" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_toLeftOf="@+id/right" android:BACkground="@color/red" > </LinearLayout> <LinearLayout android:id="@+id/right" android:layout_width="100dip" android:layout_height="fill_parent" android:layout_alignParentright="true" android:layout_alignParentTop="true" android:BACkground="@color/green" > </LinearLayout>
如果有人认为这是不可能的,那么我也可以采取实际操作或改变我的布局方法.
谢谢!
<?xml version="1.0" encoding="utf-8" ?> <RelativeLayout xmlns:android="http://scheR_434_11845@as.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <LinearLayout android:id="@+id/left" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_toLeftOf="@+id/right" android:BACkground="@color/red" > </LinearLayout> <LinearLayout android:id="@+id/right" android:layout_width="100dip" android:layout_height="fill_parent" android:layout_alignParentright="true" android:layout_alignParentTop="true" android:BACkground="@color/green" > </LinearLayout> </RelativeLayout>
编辑1:我使用背景颜色只是为了清楚地显示布局.根本没必要.
以上是大佬教程为你收集整理的右侧带有视图的Android布局,占据预设空间,左侧视图可以将屏幕的其余部分填充到一定的限制全部内容,希望文章能够帮你解决右侧带有视图的Android布局,占据预设空间,左侧视图可以将屏幕的其余部分填充到一定的限制所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。