我试图在几种布局中使用圆形形状,但由于某些原因,即使角落是圆角的,在背景中也有不是圆角的角落。 有人知道为什么吗?
代码:
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" >
LinearLayout(EditText):
<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>
看起来像这样:
谢谢
答案 0 :(得分:3)
因为对话而在额外的角落里来了。您的布局在活动和片段的情况下完美运行。对于刚刚设置的对话框
First argument must be implementation object
或者如果您发现任何其他方式将对话框背景设置为透明使用那个。
答案 1 :(得分:0)
试试吧
<?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>
答案 2 :(得分:0)
我修改了一些代码。试试看 我刚在代码中添加了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>
答案 3 :(得分:0)