运行时按钮背景颜色更改但它不会保留在圆角

时间:2013-03-05 08:51:59

标签: android android-layout android-button

我有问题我有两个按钮我用rounded_corner.xml设置Backgroung ..现在,如果我更改背景颜色运行时然后它删除圆角...如何解决这个问题..如果有人面对这个问题然后与我分享..谢谢你..

我的rounded_xml ..

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <stroke android:width="0dp" android:color="@color/green" /> 
  <corners android:radius="3dp" /> 
  <gradient android:startColor="@color/green" android:centerColor="@color/green" android:endColor="@color/green" android:angle="90" /> 
</shape>

这是我的两个按钮..

<LinearLayout
            android:id="@+id/linearLayout4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/view1"
            android:layout_below="@+id/relative_custom"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/rounded_button"
                android:text="Accer is the Best"
                android:textColor="@color/white"
                android:textStyle="bold" android:padding="5dp" android:gravity="left"/>



            <Button
                android:id="@+id/button2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_weight="1"
                android:background="@drawable/rounded_button"
                android:textColor="@color/white" android:textStyle="bold" android:padding="5dp" android:text="HP is the Best" android:gravity="left"/>

        </LinearLayout>

0 个答案:

没有答案