回答
你可以使用這個庫
https://github.com/pinball83/Masked-Edittext
[![enter image description here][1]][1]
<com.github.pinball83.maskededittext.MaskedEditText
android:id="@+id/masked_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
app:mask="*|*|*|*|*"
app:notMaskedSymbol="*"
app:maskIcon="@drawable/abc_ic_clear_mtrl_alpha"
app:maskIconColor="@color/colorPrimary"
/>
抱歉,但此代碼不起作用 – Sumit
再次檢查答案。 –
如果你從XML填充你的TextView,你可以做以下
android:text="Line1: \n Line2 \n Line3"
您還可以指定的行數與android:lines="2"
然後你就可以用\ n
它們分開此外,您可以執行以下操作(嘗試從代碼更新文本時):
String newText = "Line 1"
+ System.getProperty ("line.separator")
+ "Line 2"
+ System.getProperty ("line.separator");
單個textview將無法做到這一點。所以
嘗試
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:gravity="center"
android:text="0"
android:textSize="24sp" />
<View
android:layout_width="1dip"
android:layout_height="40dip"
android:background="#000000" />
<TextView
android:id="@+id/item2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:gravity="center"
android:text="0"
android:textSize="24sp" />
<View
android:layout_width="1dip"
android:layout_height="40dip"
android:background="#000000" />
<TextView
android:id="@+id/item3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:gravity="center"
android:text="0"
android:textSize="24sp" />
<View
android:layout_width="1dip"
android:layout_height="40dip"
android:background="#000000" />
<TextView
android:id="@+id/item4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:gravity="center"
android:text="0"
android:textSize="24sp" />
<View
android:layout_width="1dip"
android:layout_height="40dip"
android:background="#000000" />
</LinearLayout >
是不是這個有用的?@Sumit –
如果我的回答幫助你比接受作爲回答,所以其他用戶將被引導。@ Sumit –
試試這個,
main.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:padding="3dp"
android:orientation="horizontal"
android:background="@drawable/outline"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#000000"
android:gravity="center"
android:text="0"
android:textSize="20dp"/>
<View android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#353535"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#000000"
android:text="0"
android:gravity="center"
android:textSize="20dp"/>
<View android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#353535"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#000000"
android:gravity="center"
android:text="0"
android:textSize="20dp"/>
<View android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#353535"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#000000"
android:gravity="center"
android:text="0"
android:textSize="20dp"/>
<View android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#353535"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000000"
android:text="0"
android:textSize="20dp"/>
</LinearLayout>
outline.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape">
<stroke android:width="2dp" android:color="#353535" />
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp" />
<corners android:radius="0dp" />
<solid android:color="#ffffffff" />
</shape>
截圖
這種力量可以幫助你
謝謝你UI正在工作 – Sumit
請接受我的回答。那麼只有其他人可以輕鬆找到正確答案 –
- 1. 我怎麼能顯示一個字符串在textView
- 2. 我怎麼能在菜單的Dropbox添加一個分隔符
- 3. ,我怎麼能在一個字符串
- 4. 我怎麼能在一個字符串
- 5. 我怎麼能在我的網格線分隔在UWP
- 6. 我怎麼能分裂出一個行基於字符串
- 7. 我怎麼能寫字符串的一部分在Integer.toString
- 8. 我怎麼能寫一個特殊字符:「到一個文件
- 9. 我怎麼能與<br>分隔符提取文本?
- 10. 我怎麼能在RelativeLayout中居中兩個textview
- 11. 在JavaScript中,我怎麼能得到的最後一個字符的字符串
- 12. 我怎麼能在一個字符串變量
- 13. 我怎麼能寫一個字符串在Python與comparsion
- 14. 我怎麼能一個逗號分隔字符串轉換成JSON對象類型採用了棱角分明
- 15. 我怎麼能在bash腳本使用的最後一個字段的分隔符後排序
- 16. 我怎麼能分析這個XML字符串簡單的XML
- 17. 爲什麼字段分隔符必須只有一個字節?
- 18. 怎樣才能在T-SQL「/」分隔字符串幾乎最後一個子?
- 19. Bootstrap - 我怎麼能有一個粘頭?
- 20. 我怎麼能有從字符串在Ruby中
- 21. 我怎樣才能把每個記錄第一和最後一個字符在Windows分隔的文件?
- 22. 帶有HTML和分隔符的Android TextView
- 23. 我怎樣才能用連字符分割這個字符串?
- 24. 我怎麼能夠在一個字符串中使用可視化基線中的換行符
- 25. 我怎樣才能按分隔符分割數組
- 26. 我怎樣才能在一個字符串中替換多個子字符串?
- 27. 我怎麼能允許一個JList,只有唯一的字符串?
- 28. 我怎麼能聲明這是一個字符串bind_param
- 29. 我怎麼能做一個排序系統取決於字符
- 30. 我怎麼能在一個字符作爲在java中的命令行參數
你可以用|符號另外需要添加查看在TextView –
之間如何使查看 – Sumit
您需要使用單獨的TextView查看全部0的答案 –