创建Android布局以支持4“;和5“;英寸屏幕尺寸问题
我参考了更多的文件,也遇到了许多似乎是我的问题的帖子。但我想在这里得到更具体的建议或答案 问题是,我已经为5英寸手机(如nexus 4)开发了主屏幕,所以它看起来很好。当我在4英寸手机(如nexus s)上运行相同的应用程序时,主屏幕看起来不像5英寸手机“电话。这太奇怪了,有些按钮、视图都没有安装。我现在该怎么办?我还尝试创建一个单独的布局文件夹,如layout-320dp和layout normal。两个屏幕都在HDPI部分下,因此我无法创建单独的布局文件夹。此外,我在主屏幕上使用了更多的图像视图,并给出了更具体的数字值用于填充。如果我在drawable文件夹中减小图像大小,意味着我也可以在4英寸的屏幕上获得漂亮的用户界面 我的主页屏幕布局:创建Android布局以支持4“;和5“;英寸屏幕尺寸问题,android,layout,Android,Layout,我参考了更多的文件,也遇到了许多似乎是我的问题的帖子。但我想在这里得到更具体的建议或答案 问题是,我已经为5英寸手机(如nexus 4)开发了主屏幕,所以它看起来很好。当我在4英寸手机(如nexus s)上运行相同的应用程序时,主屏幕看起来不像5英寸手机“电话。这太奇怪了,有些按钮、视图都没有安装。我现在该怎么办?我还尝试创建一个单独的布局文件夹,如layout-320dp和layout normal。两个屏幕都在HDPI部分下,因此我无法创建单独的布局文件夹。此外,我在主屏幕上使用了更多的图像
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools">
<fragment
android:id="@+id/fragment_actionbar"
android:layout_width="fill_parent"
android:layout_height="44dp"
android:layout_alignParentTop="true"
android:name=".ActionbarFragment" >
<RelativeLayout
android:id="@+id/fragment_content"
android:layout_below="@id/fragment_actionbar"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id = "@+id/sty"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:background="@drawable/_splash_blank_screen"
/>
<TextView
android:id="@+id/textLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_toRightOf="@+id/girl_home"
android:textSize="14sp"
android:layout_marginTop="12dp"
android:layout_marginLeft="5dp"
android:textColor="#675836"
android:textStyle="bold" />
<TextView
android:id="@+id/textLabel_weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_below="@+id/textLabel"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/girl_home"
android:textSize="14sp"
android:textColor="#675836"
android:textStyle="bold" />
<TextView
android:id="@+id/text_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/reference_calendar_button_icon_home"
android:paddingTop="90dp"
android:paddingRight="1dip"
android:singleLine="true"
android:textColor="@color/text_highlight"
android:textSize="12sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/girl_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_marginLeft="1dp"
android:paddingLeft="1dp"
android:src="@drawable/ic_mix_match_toast"
android:singleLine="true"
/>
<ImageView
android:id="@+id/today_outfit"
android:layout_width="220dp"
android:layout_height="320dp"
android:layout_below="@+id/girl_home"
android:layout_marginTop="15dp"
android:layout_gravity="center_horizontal"
android:singleLine="true"
/>
<ImageView
android:id="@+id/reference_calendar_button_icon_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingLeft="55dp"
android:layout_toRightOf="@+id/today_outfit"
android:singleLine="true"
android:src="@drawable/btn_calendar_home" />
<ImageView
android:id="@+id/closet_button_icon_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="30dp"
android:paddingLeft="40dp"
android:layout_below="@id/text_calendar"
android:layout_toRightOf="@+id/today_outfit"
android:src="@drawable/ic_closet_home_new" />
<ImageView
android:id="@+id/search_notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="150dp"
android:paddingLeft="80dp"
android:src="@drawable/btn_search_home"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/text_weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_below="@+id/chat_button_icon_home"
android:layout_marginTop="-5dp"
android:paddingLeft="50dip"
android:textSize="12dip"
android:text="TODAY'S FORECAST"
android:textColor="@color/text_highlight"
android:textStyle="bold" />
<TextView
android:id="@+id/today_look"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_below="@+id/today_outfit"
android:paddingLeft="65dip"
android:paddingTop="1dip"
android:textSize="12sp"
android:textColor="@color/text_highlight"
android:textStyle="bold" />
<TextView
android:id="@+id/textLabel_weather_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/today_look"
android:layout_marginTop="38dp"
android:layout_marginLeft="10dp"
android:singleLine="false"
android:layout_toRightOf="@+id/chat_button_icon_home"
android:textSize="14dip"
android:textColor="#675836"
android:textStyle="bold" />
<TextView
android:id="@+id/text_window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/window_button_icon_home"
android:singleLine="true"
android:paddingLeft="260dp"
android:textColor="@color/text_highlight"
android:textSize="12sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/chat_button_icon_home"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="@+id/today_look"
android:layout_marginTop="35dp"
android:layout_marginLeft="10dp"
android:singleLine="true"
/>
<ImageView
android:id="@+id/window_button_icon_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/today_outfit"
android:layout_below="@+id/text_inspire"
android:layout_marginTop="20dp"
android:paddingLeft="30dp"
android:singleLine="true"
android:src="@drawable/btn_window_shop_new" />
<ImageView
android:id="@+id/inspire_idea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingTop="25dp"
android:singleLine="true"
android:layout_below="@+id/text_closet"
android:layout_toRightOf="@+id/today_outfit"
android:src="@drawable/btn_inspire_home" />
<TextView
android:id="@+id/text_closet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/closet_button_icon_home"
android:paddingTop="1dip"
android:paddingLeft="275dp"
android:singleLine="true"
android:textColor="@color/text_highlight"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="@+id/text_inspire"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/today_outfit"
android:paddingLeft="270dp"
android:paddingTop="-10dp"
android:singleLine="true"
android:textColor="@color/text_highlight"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
任何帮助都将不胜感激。提前感谢。您可以根据
高度和宽度创建版面文件夹。例如-layout-w360dp、layout-w480dp或layout-h480dp或layout-h600dp
。然后根据您的要求在这些版面中设置视图
编辑-
对于Nexus-4
createlayout-w720dp
和Nexus-S
和Nexus-One
createlayout-w480dp
。现在可以了。我建议您使用线性布局作为父布局,并使用权重作为权重
将屏幕等分。无需创建任何额外的布局文件夹。您使用过weightSum属性来管理视图吗?最好在此处放置一些代码粘贴您的屏幕截图和布局xml源。@SanketPandya,dilix谢谢您的回复。我已添加了布局源代码。@AhmadRaza抱歉,我无法共享screens.你的意思是我可以根据右边的宽度和高度创建一个布局文件夹,如layout-w360-hdpi,layout-w480dp-hdpi?@chain是的,你可以。我总是这样做。@chain看到这个谢谢@kanwalijit。测试后告诉你结果。我很高兴。希望它有帮助。我的主屏幕看起来像网格视图图像,所以如果我将其更改为线性布局。不,你们错了,bcs你们只需要把网格放在线性布局中,其余的充气机就可以了