我想为所有屏幕尺寸创建应用,我正在创建不同的布局文件夹,如下所示
layout
layout-sw480dp
layout-sw600dp
layout-sw720dp
layout-xlarge
并设置适当的屏幕尺寸边距并在清单文件中启用支持屏幕尺寸,但问题是,当我正在运行我的应用时,它会为我的任何屏幕尺寸运行正常的默认布局做错了请告诉我。
清单中的包括
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:resizeable="true"
android:xlargeScreens="true" />
和
<activity android:name="com.myproject.demo"
android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|uiMode|screenLayout" android:hardwareAccelerated="true">
</activity>
根据PercentRelativeLayout
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradiant"
>
<FrameLayout
android:layout_width="match_parent"
app:layout_heightPercent="100%"
app:layout_marginLeftPercent="5%"
app:layout_marginRightPercent="5%"
app:layout_marginTopPercent="5%"
>
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_marginBottomPercent="22%"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageBack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/card1"
android:scaleType="centerCrop"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ImageView
android:layout_width="match_parent"
app:layout_heightPercent="15%"
android:src="@drawable/ps"
android:id="@+id/imageViewd"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:layout_marginTopPercent="8%" />
<Button
android:id="@+id/sndmulmsg"
app:layout_widthPercent="50%"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@layout/mybuttons"
android:text="Send"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="40px"
android:layout_alignBottom="@+id/imageBack"
android:layout_centerHorizontal="true"
app:layout_marginBottomPercent="2%"
/>
<EditText
android:id="@+id/mulmono"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:hint="Enter No's 91**********,91**********"
android:inputType="phone"
android:lines="2"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_below="@+id/imageViewd"
android:layout_toRightOf="@+id/relativeLayout5"
android:layout_toLeftOf="@+id/madd"
android:layout_toStartOf="@+id/madd"
app:layout_marginTopPercent="7%"
app:layout_marginRightPercent="3%"
app:layout_marginLeftPercent="3%">
</EditText>
<Button
android:id="@+id/madd"
style="?android:attr/buttonStyleSmall"
app:layout_widthPercent="17%"
android:layout_height="wrap_content"
android:background="@layout/mybuttons"
android:text="@string/addcontact"
android:textColor="#ffffff"
android:layout_alignBottom="@+id/mulmono"
android:layout_alignRight="@+id/mulmsg"
android:layout_alignEnd="@+id/mulmsg"
app:layout_marginRightPercent="3%" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Schedule"
android:id="@+id/schedule"
android:layout_below="@+id/mulmsg"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:layout_marginTopPercent="5%"
app:layout_marginRightPercent="3%" />
<CheckBox
android:id="@+id/mulflash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Flash"
android:paddingLeft="10dp"
android:layout_below="@+id/mulmsg"
app:layout_marginTopPercent="6%"
app:layout_marginLeftPercent="5%"
/>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/sndmulmsg"
app:layout_marginTopPercent="5%" />
<EditText
android:id="@+id/mulmsg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:hint="Enter Your Message here..!"
android:inputType="textMultiLine"
android:lines="3"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_below="@+id/mulmono"
android:layout_centerHorizontal="true"
app:layout_marginTopPercent="5%"
app:layout_marginLeftPercent="3%"
app:layout_marginRightPercent="3%" />
</android.support.percent.PercentRelativeLayout>
</ScrollView>
</FrameLayout>
</android.support.percent.PercentRelativeLayout>