Add a border to textureview (a professional noun is a stroke), there are three solutions:
1. Set a 9 patch, right border, the middle is empty PNG.
2. Customize a view and draw a border with canvas.
3. Use the shapedrawable provided by Android to define a border.
Personal comparisons suggest a third way, because the third is written in XML, fast, resource-intensive, and less code-writing, easy to maintain.
Use the following methods:
1. Define a background.xml file.
Copy Code code as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >
<stroke
Android:width= "2DP"
Android:color= "#0000AA"/>
</shape> <span></span>
2. Use it when setting the background of SRC in view.
Copy Code code as follows:
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:gravity= "Center"
android:src= "@drawable/background"
android:padding= "2DP" >
<textureview
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"/>
<com.android.camera.ui.rotatelayout
Android:layout_width= "Wrap_content"
Android:layout_width= "Wrap_content" >
<textview
Android:layout_width= "Wrap_content"
Android:layout_width= "Wrap_content"
Android:textcolor= "#FFFFFF"
Android:textsize= "22SP"
android:background= "#0000000"/>
</com.android.camera.ui.RoateLayout>
</RelativeLayout>
The
Note is that I set the drawable for the Textureview parent container relativelayout and set padding.