Android layout 将屏幕分成三种不同的大小
在我的应用程序屏幕中,有两个列表视图,分别是L1(填充数据D1)和L2(填充数据D2),屏幕底部有一个按钮 显示列表的条件:Android layout 将屏幕分成三种不同的大小,android-layout,Android Layout,在我的应用程序屏幕中,有两个列表视图,分别是L1(填充数据D1)和L2(填充数据D2),屏幕底部有一个按钮 显示列表的条件: if(show D1){ //Display L1 list in the middle of screen and button at the bottom of screen. //Hide L2 } if(show D2){ //Display L2 list in the middle of screen and button at the bo
if(show D1){
//Display L1 list in the middle of screen and button at the bottom of screen.
//Hide L2
}
if(show D2){
//Display L2 list in the middle of screen and button at the bottom of screen.
//Hide L1
}
if(show D1 && D2){
if(D1>=D2){
//Display L1 and L2 lists in the middle of screen and
//button at the bottom of screen.
}else if(D1<D2){
//Display L1 and L2 lists in the middle of screen and
//button at the bottom of screen.
}
}
if(显示D1){
//显示屏幕中部的L1列表和屏幕底部的按钮。
//隐藏L2
}
如果(显示D2){
//显示屏幕中间的L2列表和屏幕底部的按钮。
//隐藏L1
}
如果(显示D1和D2){
如果(D1>=D2){
//在屏幕中部显示L1和L2列表
//按钮在屏幕底部。
}否则,如果(d1)将父布局设为相对布局..M S Gadag如果父布局为相对布局,则权重属性将不适用于子布局使用下面的子布局n在您使用布局参数编码时调整它。。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background_main"
>
<LinearLayout
android:id="@+id/layout1"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txtSubHeadingW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:layout_marginTop="2dp"
android:paddingLeft="18dp"
android:gravity="center"
android:maxLines="1"
android:text="@string/lbl1"
android:textColor="@color/BlueViolet"
android:textStyle="bold" style="@style/style_text"
/>
<ListView
android:id="@+id/l1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:cacheColorHint="#00000000"
/>
</LinearLayout>
<LinearLayout android:id="@+id/layout2"
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtSubHeadingT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="18dp"
android:gravity="center"
android:maxLines="1"
android:text="@string/lbl2"
android:textColor="@color/BlueViolet"
android:textStyle="bold"
android:visibility="gone" style="@style/style_text"
/>
<ListView
android:id="@+id/l2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:cacheColorHint="#00000000"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/lnrControls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dip"
android:background="@drawable/top_portrait"
android:gravity="center"
android:orientation="horizontal"
android:padding="3dip"
>
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_text_selector"
android:text="@string/lbl_ok"
android:gravity="center"
android:textColor="@color/White"
android:layout_gravity="center" style="@style/style_text"
/>
</LinearLayout>
</LinearLayout>