繁体   English   中英

Android Drawable Shape Ring在较低的API级别

[英]Android Drawable Shape Ring in lower API level

我已经定义了一个简单的环形绘图,可以将它用作按钮背景。 我是这样做的:

 <shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="ring"
   android:innerRadius="20dp"
     android:thickness="1dp"
     android:useLevel ="false"
    >   
   <solid
     android:color="@color/lines" />
     />

</shape>  

我在相对布局中使用它,如:

     <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="30dip"
android:orientation="vertical">

<TextView
    android:text="@string/start_game"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    />

<Button android:id="@+id/start"
 android:layout_height="wrap_content" 
 android:layout_width="wrap_content"  
android:background="@layout/round_button"  
  android:layout_alignParentBottom="true"
   />

</RelativeLayout>

其中round_button是我的xml文件,我在其中定义了环。 当我将最低sdk级别设置为11或更高时,它给出了完美的结果。 但问题是,当我尝试将其更改为较低的api级别时,例如3,环不会出现! 我在这里失踪了什么?

我遇到过类似的东西。 我通过在形状上将useLevel属性设置为false来修复它,如下所示:

<shape android:shape="ring"
        android:thickness="@dimen/indicatorcircle_thickness"
        android:useLevel="false">
        <size android:width="@dimen/indicatorcircle_size" android:height="@dimen/indicatorcircle_size"/>
        <solid android:color="@color/white"/>
</shape>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM