【问题标题】:Android Drawable Shape Ring in lower API level较低 API 级别的 Android Drawable Shape Ring
【发布时间】:2012-03-18 15:56:53
【问题描述】:

我定义了一个简单的环形可绘制对象,将其用作按钮背景。 这是我的做法:

 <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,环没有出现! 我在这里错过了什么?

【问题讨论】:

    标签: android drawable shape


    【解决方案1】:

    我遇到过类似的事情。我通过在形状上将 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      • 1970-01-01
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2021-10-22
      • 2015-03-13
      相关资源
      最近更新 更多