[英]Android round shape corners not round
我正在嘗試在幾種布局中使用圓角形狀,但是由於某些原因,即使拐角是圓角的,在背景中也有一些角不是圓角的。 有人知道為什么嗎?
碼:
dialog_background:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/jobim_white" ></solid>
<stroke
android:width="1dp"
android:color="@color/colorPrimary" ></stroke>
<corners android:radius="8dp"></corners>
</shape>
search_edittext_shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp" >
<solid android:color="#FFFFFF" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
RelativeLayout(對話框的):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dialog_background" >
(EditText的)LinearLayout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#ECECEC">
<EditText
android:id="@+id/searchTypeEdtTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_search"
android:drawableTint="#D0D0D0"
android:background="@drawable/search_edittext_shape"
android:hint="@string/search"
android:textColorHint="#ECECEC"
android:elevation="3dp"
android:textCursorDrawable="@drawable/cursor_color" />
</LinearLayout>
看起來像這樣:
謝謝
由於對話,在更多角落出現了。 您的布局可以完美地處理活動和碎片。 對於剛剛設置的對話框
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
或者,如果您找到其他方法將對話框背景設置為透明,請使用該方法。
試試吧
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<corners android:radius="3dip" />
<stroke
android:width="1dp"
android:color="#ADADAD" />
</shape>
我已經修改了一些代碼。 嘗試我剛剛在您的代碼中添加了形狀標簽。 它將為您工作。
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/jobim_white" ></solid>
<stroke
android:width="1dp"
android:color="@color/colorPrimary" ></stroke>
<corners android:radius="8dp"></corners>
</shape>
用於編輯文本,使用rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- view background color -->
<solid
android:color="@color/colorPrimary" >
</solid>
<!-- If you want to add some padding -->
<padding
android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp" >
</padding>
<!-- Here is the corner radius -->
<corners
android:radius="20dp" >
</corners>
</shape>
在您的LinearLayout中
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#ECECEC">
<EditText
android:id="@+id/searchTypeEdtTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_action_search"
android:drawableTint="#D0D0D0"
android:background="@drawable/rounded_corner"
android:hint="@string/search"
android:textColorHint="#ECECEC"
android:textCursorDrawable="@color/black" />
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.