我有一些XML在API级别高于17的情况下运行良好,但在API级别低于17的手机上显示不同。我15岁。
我应该单独做v-17,v-16,v-15的布局,还是有其他方法可以同时适用于这三种情况?
在设备上显示不同行为的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/verify_number_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/app_name_id"
android:layout_marginLeft="17dp"
android:layout_marginRight="17dp"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:visibility="visible"
tools:context=".activities.LoginActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="24dp"
android:layout_marginTop="30dp"
android:background="@drawable/outline"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<customViews.TextViewPlus
android:id="@+id/tv_state_code"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:gravity="center|center_horizontal"
android:text="@string/country_code_text"
android:textColor="@color/text_color"
android:textSize="16sp"
app:font="OpenSans-Regular.ttf" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@android:color/white" />
<customViews.EditTextPlus
android:id="@+id/et_mobile"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center|center_horizontal"
android:layout_marginLeft="8dp"
android:layout_weight="0.7"
android:gravity="start|center_vertical"
android:hint="@string/mobile_number_hint"
android:imeOptions="actionDone"
android:inputType="phone"
android:maxLength="10"
android:maxLines="1"
android:background="@android:color/transparent"
android:textColor="@color/textview_color_selector"
android:textCursorDrawable="@null"
android:textSize="16sp"
app:font="OpenSans-Regular.ttf" />
</LinearLayout>
<customViews.ButtonPlus
android:id="@+id/next_button"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="@drawable/outline"
android:gravity="center"
android:text="@string/next_button"
android:textColor="@color/textview_color_selector"
android:textSize="17sp"
app:font="Oswald-Light.ttf" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="46dp"
android:layout_gravity="center_horizontal"
android:indeterminate="true"
android:indeterminateTint="@color/text_color"
android:visibility="invisible" />
</LinearLayout>
outline.xml可在上面使用,并以不同的方式显示:
<?xml version="1.0" encoding="utf-8"?><!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<stroke
android:width="0.7pt"
android:color="#FFFF" />
<corners
android:bottomLeftRadius="55dp"
android:bottomRightRadius="55dp"
android:topLeftRadius="55dp"
android:topRightRadius="55dp" />
</shape>
17以上设备上的XML图像:
下图见API 17:
请给我个建议。
最佳答案
请修改可绘制的拐角并更改半径。需要像这样减小半径大小-
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<stroke
android:width="0.7pt"
android:color="#FFFF" />
<corners
android:bottomLeftRadius="25dp"
android:bottomRightRadius="25dp"
android:topLeftRadius="25dp"
android:topRightRadius="25dp" />
</shape>
谢谢