我需要创建一个android形状,以便只有底部有笔画(虚线).当我尝试以下操作时,笔划将形状从中心平分.有谁知道怎么做对吗?中风需要是底线/边界.我使用形状作为TextView的背景.请不要在意我为什么需要它.
<?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="#1bd4f6" />
</shape>
</item>
<item>
<shape android:shape="line" >
<padding android:bottom="1dp" />
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="1dp"
android:color="#ababb2" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud) 我正在看看android SDK中的记事本示例,请看这里:http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html
事情是它只绘制光标所在的当前行,例如http://cdn2.staztic.com/screenshots/simple-notepad-app-al-1.jpg
但我想显示填满屏幕的线条,例如http://www.itismyworld.info/wp-content/uploads/2010/03/AK-notebook.png
任何建议都会很棒.相关的代码似乎在这里:
protected void onDraw(Canvas canvas) {
// Gets the number of lines of text in the View.
int count = getLineCount();
// Gets the global Rect and Paint objects
Rect r = mRect;
Paint paint = mPaint;
/*
* Draws one line in the rectangle for every line of text in the EditText
*/
for (int i = 0; i < count; i++) {
// Gets the baseline coordinates for the …Run Code Online (Sandbox Code Playgroud)