Android: Stroke Left Side of Button Only
You can try this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#FF8888" />
</shape>
</item>
<item
android:drawable="@drawable/shape2"
android:left="1dp">
</item>
</layer-list>
Where @drawable/shape2
is the shape you specified above
result:
How to draw border on just one side of a linear layout?
You can use this to get border on one side
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
</shape>
</item>
<item android:left="5dp">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
</layer-list>
EDITED
As many including me wanted to have a one side border with transparent background, I have implemented a BorderDrawable
which could give me borders with different size and color in the same way as we use css. But this could not be used via xml. For supporting XML, I have added a BorderFrameLayout
in which your layout can be wrapped.
See my github for the complete source.
Related Topics
Error: Execution Failed for Task ':App:Clean'. Unable to Delete File
Dynamically Updating an Autocompletetextview Adapter
Detect Back Button But Don't Dismiss Dialogfragment
Emulator Appearing Offline on M1 MAC After the Last Update of Arm64-V8A
How to Play Audio File in Android
Create/Copy File in Android Q Using Mediastore
Android M Weird Shared Preferences Issue
Android Httpclient Hangs on Second Request to the Server (Connection Timed Out)
How to Add a Button to a Preferencescreen
Android Navigation Architecture Component - Get Current Visible Fragment
How to Compile a Static Library Using the Android Ndk
Android: How to Get Gsm Signal Strength for All Available Network Operators
Performing Action After Fragment Transaction Animation Is Finished
Android Webview with Client Certificate
Run-As Package 'A.B.C' Is Unknown - Galaxy S4 Jellybean or Android 4.3