如何布局在Android的各种屏幕支持?
我正在开发使用的GridView图库查看,在小屏幕上我的布局设计,固定得非常好,但大屏幕没有我的设计,在大屏幕有一定的空间的波纹管加载更多图片按钮指fig2,我怎么能解决这个问题问题,我的清单文件中加入这一行的支持不同的屏幕,请给一些样品code对我来说..
i am developing gallery view using gridview,in small screen my layout design fixed very well,but large screen did not my design,In large screen have some spaces bellow "load more picture" button refer fig2,how can i solve this problem,my Manifest file added this lines for support various screen,please give some sample code for me..
<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:anyDensity="false" />
和我的XML code
and my xml code
<?xml version="1.0" encoding="utf-8"?>
<merge android:layout_width="wrap_content" android:layout_height="340dp" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="335dp" android:orientation="vertical"
android:background="@color/black">
<GridView
android:id="@+id/jr_lookbook_grid" android:layout_width="fill_parent"
android:layout_height="335dp" android:numColumns="4"
android:verticalSpacing="10dp" android:horizontalSpacing="10dp"
android:columnWidth="90dp" android:stretchMode="columnWidth"
android:adjustViewBounds="true"
android:background="@drawable/shape"
android:gravity="center" android:layout_weight="1"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout0209_img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="311dp">
<Button android:id="@+id/click"
android:background="#AA000000"
android:text="Load More Pictures..."
android:textColor="@color/white"
android:layout_width="fill_parent" android:layout_height="30dp"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout02_img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:background="@color/black"
android:layout_alignParentLeft="true">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" />
<ImageView android:id="@+id/ImageView01"
android:layout_gravity="center_horizontal"
android:scaleType="centerInside"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true">
</ImageView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02" android:background="#AA000000"
android:layout_width="400px"
android:layout_height="50dp"
android:layout_gravity="bottom">
<Button
android:id="@+id/back
android:layout_height="wrap_content"
android:background="@drawable/back1"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp" /
<Button
android:background="@drawable/forward5"
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentRight="true"
android:layout_marginLeft="150dp"/>
<Button
android:background="@drawable/menushare"
android:id="@+id/photoshare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentRight="true"
android:layout_marginLeft="20dip" />
</LinearLayout>
</merge>
感谢所有
您必须编写XML code大屏幕。我想您把XML文件在res /布局文件夹中。如果它是你可以保持三个文件夹,以区分不同的屏幕像RES /布局小,RES /布局,RES /布局长。在这三个文件夹,你可以设置不同的alignements不同类型的屏幕。对于中型屏幕,让你的XML code布局,并为小屏幕 - 保持在布局小等,并设置
You have to write xml code for large screen. I think you are keeping your xml file in res/layout folder. if it is you can keep three folders to differentiate various screens like res/layout-small, res/layout, res/layout-long. In these three folders you can set different alignements to various screen types. For Medium Screen, keep your xml code in layout, and for small screens - keep it in layout-small and etc., and set
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
这些线在你的AndroidManifest.xml
these lines in your AndroidManifest.xml