[英]How i can split a textview?
我認為我的問題是基本的。 但是,我找不到有關此以及如何執行此操作的信息。
是否可以拆分textview? 在textview的中間放一行?
**TextView**
________________
| |
|________________|
| |
|________________|
另一件事...。想象一下,textview的高度為100dip。 可能只有textview的前10%是彩色的嗎? 僅上色10dp?
有人可以幫忙嗎? 謝謝您四個的時間和幫助。
首先,您無法拆分TextView。 但是您可以通過將正確的圖像設置為android:setDrawableBottom="yourImage"
您可以自定義View
通過overrideing在Android中onDraw
該方法View
。
您可能會考慮的是:
@Override
protected void onDraw(Canvas canvas) {
// paint a line through the centre
Paint paint = new Paint();
canvas.drawLine(0, canvas.getWidth(), canvas.getHeight()/2,
canvas.getHeight()/2, paint);
super.onDraw(canvas);
}
這將通過View
的中心(在您的情況下為TextView
)繪制一條線。 您可以為10%/ 90%的着色使用相同的方法。
例如。
@Override
protected void onDraw(Canvas canvas) {
// paint a region blue
Paint paint = new Paint();
paint.setColor(Color.BLUE);//or whatever colour you want
canvas.drawRect(0, canvas.getHeight()/10, canvas.getWidth(),
canvas.getHeight(), paint)
super.onDraw(canvas);
}
Draw rect采用以下參數:
canvas.drawRect(left, top, right, bottom, paint)
還有一些替代方法,您可以在其中傳遞實際的圖紙Rectangle等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.