[英]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.