Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓圆形角不圆_Android_Android Layout_Layout - Fatal编程技术网

Android 安卓圆形角不圆

Android 安卓圆形角不圆,android,android-layout,layout,Android,Android Layout,Layout,我试图在一些布局中使用圆角形状,但出于某种原因,即使角是圆角,背景中也有一些角不是圆角。 有人知道为什么吗 代码: 对话背景: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/jobim_white" ></solid> <stroke androi

我试图在一些布局中使用圆角形状,但出于某种原因,即使角是圆角,背景中也有一些角不是圆角。 有人知道为什么吗

代码:

对话背景:

<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>

搜索\u编辑文本\u形状:

<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>

(对话框的)相对长度:


(编辑文本的)线性布局:


看起来像这样:

谢谢

试试看

<?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="#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
            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>

我修改了您的一些代码。试试看 我刚刚在代码中添加了形状标记。这对你有用

<?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
            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>

您的背景没有问题,可以绘制。这里的问题是对话主题

按照建议,尝试将对话框背景设置为透明


如果这无助于尝试将主题更改为自定义主题,正如建议的那样

您的背景没有问题,并且可以绘制。这里的问题是对话主题

按照建议,尝试将对话框背景设置为透明


如果这样做无济于事,请尝试将主题更改为自定义主题,正如建议的那样,

由于对话框的原因,会出现额外的角落。在出现活动和碎片的情况下,您的布局非常有效。对于刚刚设置的对话框

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 

或者,如果您发现任何其他方法可以将对话框背景设置为透明,请使用该方法。

由于对话框的原因,额外的角会出现。在出现活动和碎片的情况下,您的布局非常有效。对于刚刚设置的对话框

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 



或者,如果您发现了任何其他将对话框背景设置为透明的方法,请使用该方法。

My bad。。。就是在格式化对话框中迷失了方向。getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT));试试愤怒的工具。com@henengel更新我的帖子并在我身边运行。它对我很有效,所以现在就试试吧。它也会对你有用。@henengel你试过我更新的解决方案吗?我的坏。。。就是在格式化对话框中迷失了方向。getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT));试试愤怒的工具。com@henengel更新我的帖子并在我身边运行。它对我很有效,所以现在就试试吧。它也会对你有用。@henengel你试过我更新的解决方案吗?我需要一个圆角矩形,不是oval@ManikandanK检查过了。除了笔划颜色不同,看起来是一样的,有问题。@ManikandanK我这样做了,它确实有效,但总的来说,我仍然有问题。我还在EditText上使用该形状,并且有相同的问题。因为我使用的是setBackgroundDrawable,所以我不能用它来设置背景透明度。有什么想法吗?——我需要一个圆角矩形,不是吗oval@ManikandanK检查过了。除了笔划颜色不同,看起来是一样的,有问题。@ManikandanK我这样做了,它确实有效,但总的来说,我仍然有问题。我还在EditText上使用该形状,并且有相同的问题。因为我使用的是setBackgroundDrawable,所以我不能用它来设置背景透明度。有什么想法吗?——@henengel add dialog.getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT))。这样做了,并且确实解决了对话框问题。还有文本吗problem@henengel我已经根据您对编辑文本的要求更改了我的帖子。试试这个。您也可以在此处尝试编辑文本样式。尝试后无效。非圆形的角落更为明显。@henengel我再次更新了我的帖子,并在我身边运行它。它很好用,所以现在就试试吧。它也适用于您。@henengel add dialog.getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT))。它解决了对话框问题。还有文本吗problem@henengel我已经根据您对编辑文本的要求更改了我的帖子。试试这个。您也可以在此处尝试编辑文本样式。尝试后无效。非圆形的角落更为明显。@henengel我再次更新了我的帖子,并在我身边运行它。它很好用,所以现在就试试吧。它也适用于您。这确实适用于对话框。我还在EditText上使用该形状,并且有相同的问题。因为我使用的是setBackgroundDrawable,所以我不能用它来设置背景透明度。知道吗?在edittext图像中,你得到的是哪种编辑文本?@henengel你试过我更新的文章中的编辑文本吗?@DeepakSachdeva是的,我现在试过了,但没用。仍然是相同的问题。这确实适用于对话框。我还在EditText上使用该形状,并且有相同的问题。因为我使用的是setBackgroundDrawable,所以我不能用它来设置背景透明度。知道吗?在edittext图像中,你得到的是哪种编辑文本?@henengel你试过我更新的文章中的编辑文本吗?@DeepakSachdeva是的,我现在试过了,但没用。仍然是相同的问题。这可能会修复对话框问题,但不会修复EditText问题。dialog.getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT))也修复了对话框问题。这可能修复了对话框问题,但无法修复EditText问题。dialog.getWindow().setBackgroundDrawable(新的ColorDrawable(Color.TRANSPARENT))也修复了对话框问题。