Reputation: 534
I created a navigation bar using LinearLayout containing Clickable TextView's, for the containing LinearLayout I set a background shape XML for creating rounded corners, the problem is, when the user click on one of the tabs I set to the tab color backround, the rounded corners overwriting, the reason I set the rounded corners in the container and not in the tabs is because the right-left\left-right languages.
Before clicking
After clicking
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="@drawable/rounded_corners"
android:layout_height="40dp"
android:layout_margin="10dp">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="@color/registerButton"
android:gravity="center"
android:text="A"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/registerButton">
</View>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="@color/registerButton"
android:text="B"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/registerButton">
</View>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="@color/registerButton"
android:gravity="center"
android:text="C"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/registerButton">
</View>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="@color/registerButton"
android:gravity="center"
android:text="D"/>
@drawable/rounded_corners
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dip" android:color="@color/registerButton" />
<corners android:radius="8dip"/>
<padding android:color="@color/registerButton"
android:left="0dip"
android:top="0dip"
android:right="0dip"
android:bottom="0dip" />
</shape>
Upvotes: 10
Views: 2076
Reputation: 1705
Create another xml file as below and save it in drawables folder.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#0066ff"/> //new blue color, change the color code as you wish
<stroke android:width="1dip" android:color="@color/registerButton" />
<corners android:radius="8dip"/>
<padding android:color="@color/registerButton"
android:left="0dip"
android:top="0dip"
android:right="0dip"
android:bottom="0dip" />
</shape>
in your java class file, handle onclick and set the background to newly created file.
Upvotes: 0
Reputation: 407
First you have to make a distinct selector for text view A where you need to set corner in your selector file:
<corners
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp">
</corners>
change value of radiaus as per your need
Upvotes: 1