在Android的TABS圆角 [英] Rounded corners for TABS in android

查看:189
本文介绍了在Android的TABS圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现的圆角,我在我的应用程序已经构造的标签。到目前为止,我能想出这个

I want to achieve rounded corners for the tab that I've constructed in my application. So far I was able to come up with this

我想我的圆角看起来如此。 (我codeD它只有左,右角落出现这样一种方式,但是,当状态改变时它看起来像上面的图片)

I would like my rounded corners to look as so. (I've coded it in such a way that only the right and left corners appear but when the states change it looks like the above image)

下面是我到目前为止写的code。如何能够做到通过code适当的圆角?

Below is the code that I've written so far. How can I achieve proper rounded corners through code ?

SELECTED TAB.XML

SELECTED TAB.XML

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
    android:topRightRadius="10dp"
    android:bottomLeftRadius="10dp"/>

<gradient
    android:startColor="#000" 
    android:endColor="#000"
    android:gradientRadius="400"
    android:angle="-270"/>

</shape>

未选定TAB.XML

UNSELECTED TAB.XML

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient 
android:angle="90" 
android:startColor="#880f0f10" 
android:centerColor="#8858585a" 
android:endColor="#88a9a9a9"/>

 <corners
    android:topLeftRadius="10dp"
    android:bottomRightRadius="10dp"/>

</shape>

感谢您的答复! :)

Thanks for your response !! :)

推荐答案

我认为你应该使用4形状:

I think you should use 4 shapes:


  • 对于未选择左键

  • for left button not selected

选定左键

对于未选择右键

有关选择右键

然后写选择用于按钮的背景下,见范例左键(为右只是类似):

And then write selector to use for button background, see example for the left button (for the right just the similar):

<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_selected="true">
<shape android:shape="rectangle">
  <corners
    android:topRightRadius="10dp"
    android:bottomLeftRadius="10dp"/>
  <gradient
    android:startColor="#000"
    android:endColor="#000"
    android:gradientRadius="400"
    android:angle="-270"/>
</shape>
</item>

<item>
    <shape android:shape="rectangle">
      <gradient
        android:angle="90"
        android:startColor="#880f0f10"
        android:centerColor="#8858585a"
        android:endColor="#88a9a9a9"/>
   <corners
      android:topRightRadius="10dp"
      android:bottomLeftRadius="10dp"/>
</shape>
</item></selector>

这篇关于在Android的TABS圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆