導航:首頁 > 操作系統 > android設置textview邊框

android設置textview邊框

發布時間:2022-05-30 23:13:07

android multiautocompletetextview 怎麼設置邊框樣式

自己復寫下拉的adapter 然後在adapter中載入自己的layout 然後設置layout中TextView為顯示不全時滾動

② Android怎麼讓TextView的邊框只有左,上和底部

可以自定義邊框的,設置textview的背景就行了。有下面兩種方法:

  1. 自己弄一張.9圖,只有需求的三個邊,然後backgroud設置為該圖片;

  2. 自己寫個xml的drawable,同樣只弄需要的三個邊,同樣設置為background;

這是比較常用的兩個方式吧。

③ 怎麼讓textview呈現出一個黑色邊框

主要有三種方式可以實現:

  1. 帶有邊框的透明圖片

  2. 使用xml的shape設置

  3. 繼承TextView覆寫onDraw方法。

方法一:

帶有透明圖片的背景圖,只要設置background="#00000"就可以了。

方法二:

通過shape來設置背景圖片

首先一個textview_border.xml文件放在drawable文件夾裡面

<?xmlversion="1.0"encoding="utf-8"?>

<shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle">

<solidandroid:color="#ffffff"/>

<strokeandroid:width="1dip"android:color="#4fa5d5"/>

</shape>

為要添加邊框的TextView添加一個background

android:background="@drawable/textview_border"

方法三:

編寫一個繼承TextView類的自定義組件,並在onDraw事件方法中畫邊框。

packagecom.example.test;

importandroid.annotation.SuppressLint;

importandroid.content.Context;

importandroid.graphics.Canvas;

importandroid.graphics.Paint;

importandroid.util.AttributeSet;

importandroid.widget.TextView;

@SuppressLint("DrawAllocation")

{

publicBorderTextView(Contextcontext){

super(context);

}

publicBorderTextView(Contextcontext,AttributeSetattrs){

super(context,attrs);

}

privateintsroke_width=1;

@Override

protectedvoidonDraw(Canvascanvas){

Paintpaint=newPaint();

//將邊框設為黑色

paint.setColor(android.graphics.Color.BLACK);

//畫TextView的4個邊

canvas.drawLine(0,0,this.getWidth()-sroke_width,0,paint);

canvas.drawLine(0,0,0,this.getHeight()-sroke_width,paint);

canvas.drawLine(this.getWidth()-sroke_width,0,this.getWidth()-sroke_width,this.getHeight()-sroke_width,paint);

canvas.drawLine(0,this.getHeight()-sroke_width,this.getWidth()-sroke_width,this.getHeight()-sroke_width,paint);

super.onDraw(canvas);

}

}

④ android不用shape怎麼給textview描邊

stroke:描邊
corners:圓角
padding:間隔

Shape的使用如下,製作橢圓形邊框textview_bg.xml。

[html] view plain
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="#ffffff" /> <!-- 定義填充的顏色值 -->

⑤ 給textview設置四周邊框

您好,1、設置四周邊框
<?xml version="1.0"encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke android:width="2dip"android:color="#ff000000" />
</shape>
2、只設置底部邊框
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the main color -->
<item>
<shape>
<solid android:color="#ffa8abad" />
</shape>
</item>
<!-- This is the line -->
<item android:bottom="2dp">
<shape>
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>

⑥ 怎麼給android 設置邊框

邊框主要是使用shape文件,可以定製左右上下的邊框,如果想要隱藏某部分,設置我透明即可。

⑦ android 怎麼在程代碼中給textview加下邊框xml方式我已會了!

給TextView加下邊框是不是就是在TetView下面劃一條線,如果是這樣的話方法有很多:相對布局、透明圖片、重寫onDraw都可以,我告訴你個及其取巧的方法:
1.tv.setText(Html.fromHtml("<b>附件:</b>"
+ "<a href=\"http://www.google.com\">"+這里填寫TextView的值+"</a>"));
2.tv.setMovementMethod(LinkMovementMethod.getInstance());
這是可以跳轉的,如果不要執行跳轉動作,把第2條語句注釋掉

⑧ 如何設置textview的邊框

先寫drawable裡面的xml文件,裡面設置shape來設置文本框的特殊效果。

[java] view plain
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 實心 -->
<solid android:color="@android:color/white" />
<!-- 邊框 -->
<stroke
android:width="0.5dp"
android:color="@android:color/black" />
<!-- 圓角 -->
<corners android:radius="3dp" />
<!-- 邊距 -->
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<!-- 漸變 -->
<gradient
android:angle="270"
android:endColor="#FFFF782"
android:startColor="#13C7AF" />

</shape>

基本上常用的就這幾種了,要達到很好的效果,你需要重新細致的改寫裡面的數據。

下面是要用到這個shape的LineLayout,在裡面設置了3個TextView,沒設置對其的方式,默認是向做靠齊的。

[java] view plain
<?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="match_parent"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tvbar"
android:text="hello" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tvbar"
android:text="hello" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tvbar"
android:text="hello" />

</LinearLayout>

⑨ 怎樣在textview中給文字加上邊框

可以讓TextView填滿整個父控制項,然後設置與父控制項間的邊距,再將父控制項的背景設置成黑,這樣TextView就有一個黑色邊框了。。。

閱讀全文

與android設置textview邊框相關的資料

熱點內容
自己購買雲主伺服器推薦 瀏覽:419
個人所得稅java 瀏覽:761
多餘的伺服器滑道還有什麼用 瀏覽:189
pdf劈開合並 瀏覽:27
不能修改的pdf 瀏覽:751
同城公眾源碼 瀏覽:488
一個伺服器2個埠怎麼映射 瀏覽:297
java字元串ascii碼 瀏覽:78
台灣雲伺服器怎麼租伺服器 瀏覽:475
旅遊手機網站源碼 瀏覽:332
android關聯表 瀏覽:945
安卓導航無聲音怎麼維修 瀏覽:332
app怎麼裝視頻 瀏覽:430
安卓系統下的軟體怎麼移到桌面 瀏覽:96
windows拷貝到linux 瀏覽:772
mdr軟體解壓和別人不一樣 瀏覽:904
單片機串列通信有什麼好處 瀏覽:340
游戲開發程序員書籍 瀏覽:860
pdf中圖片修改 瀏覽:288
匯編編譯後 瀏覽:491