In my android application activity, I need to arrange 6 buttons as shown below: The buttons are named from 1 to 6. When I try to add each button as background to the buttons, there is a problem that the buttons are overlapping each other. The background png image of the button are triangular in shape. When I add these background png to the buttons, its background image changes, but the borders of the button are still rectangle in shape. So I need the buttons with triangular borders, so that I can place them in a format like the below screenshot. Also I don't which layout suits most for this type pattern. So please do suggest that also..
Try this for triangle shape: call it as a background for your textview or any.
triangle.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="100%"
>
<shape android:shape="rectangle">
<corners android:radius="15dip" />
<solid android:color="@color/blue" />
</shape>
</rotate>
</item>
</layer-list>
//TEXTVIEW CALLING
<TextView
android:layout_width="@dimen/triangle"
android:layout_height="@dimen/triangle"
android:rotation="90"
android:layout_centerVertical="true"
android:background="@drawable/triangle"/>
Check this answer of mine, i think you can follow this approach to achieve your goal.. [How to make ImageButtons bounds wrap around the image?
来源:https://stackoverflow.com/questions/25398788/triangular-shaped-button-for-android-activity