導航:首頁 > 操作系統 > androidtextview邊框線

androidtextview邊框線

發布時間:2024-05-11 13:21:57

android TextView 文字周邊的空白部分是多少

控制項之間的間距有兩種設置:
android:layout_margin="10dp" 外邊距

android:padding="10dp" 內邊距

Android中 padding和margin的簡單地理解:margin為外邊距,padding為內邊距。
1.padding的常用屬性:
android:paddingTop
android:paddingBottom
android:paddingLeft
android:paddingRight

2.margin的常用屬性:
android:layout_marginTop
android:layout_marginBottom
android:layout_marginLeft
android:layout_marginRight

Ⅱ android 如何去掉edittext上邊框

將edittext的style設置成?android:attr/textViewStyle 取消掉默認的樣式,在設置background為@null接下來就是一個空空的edittext了(比如http://www.tiecou.com/)
, 在兩個edittext中間加一個view,設置background為灰色,寬度match_parent,高度2dip看看。

RelativeLayout xmlns:android="

xmlns:tools="

android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/white"
android:orientation="vertical" >

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="輸入用戶名"
android:paddingBottom="5dip"
android:paddingTop="5dip" />

<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@android:color/darker_gray" />

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="輸入密碼"
android:inputType="textPassword"
android:paddingBottom="5dip"
android:paddingTop="5dip" />
</LinearLayout>
</RelativeLayout>

Ⅲ 怎麼給android 設置邊框

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

Ⅳ android TextView中如何設置下劃線

1. TextView tv=new TextView(this);
tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下劃線
tv.setText("使用代碼實現下劃線樣式");
tv.setTextColor(Color.WHITE);

2. tv=new TextView(this);
tv.setText(Html.fromHtml("<u>使用html實現下劃線樣式</u>"));

Ⅳ <TextView ... android:padding="30px"...榪欎釜padding鏄浠涔堟剰鎬濓紵

鍝囧畨鍗撶殑錛宲adding搴旇ユ槸TextView榪欎釜鎺т歡閲岄潰鐨勫唴瀹瑰埌 鎺т歡鐨勮窛紱

娣辯伆灝辨槸padding,鐧借壊灝辨槸浣犵殑鍐呭瑰彲浠ユ斁寰楀尯鍩熴

Ⅵ 怎麼讓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的layout中畫出來一條線

可以利用TextView來實現,如果要水平線將textView的高設置為1設置背景顏色,豎線將寬設為1。如下代碼:

<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ffffff"
/>

Ⅷ Android studio創建一個靠下的文本框

建立代碼創建。
1.首先建立好兩個activity,取名分別為activity_main和activity_display_message
2.在在第一個activity的布局文件(content_main.xml)中創建一個編輯框(EditText)和一個按鈕(Button),並在按鈕中設置觸發事件sendMessage
3.在MainActivity.java下聲明一個sendMessage方法
4.在我們創建的第二個Activity的布局文件(activity_display_message.xml)下創建一個文本框(TextView)並設置id
5.打開DisplayMessageActivity.java在onCreat方法中添加代碼
這樣就實現了一個簡單的、線性布局下的編輯框向文本框傳輸數據的簡單功能。

閱讀全文

與androidtextview邊框線相關的資料

熱點內容
怎麼移動文件夾到另一個文件夾中 瀏覽:291
240b控台編程視頻教程 瀏覽:798
python編程退出程序 瀏覽:782
攝影投票評比小程序源碼 瀏覽:619
linux串口編程read 瀏覽:582
吃飯解壓視頻動畫 瀏覽:899
阿里雲伺服器怎麼才算好 瀏覽:7
炮神命令部隊進攻 瀏覽:497
三星壓縮機sk190h參數 瀏覽:1002
解壓到硬碟好難怎麼辦 瀏覽:25
socket介面java 瀏覽:232
壓縮機cad圖 瀏覽:389
java內聚 瀏覽:550
pythonopencvmask 瀏覽:983
java地址解析 瀏覽:306
高級編程培訓班需要多少費用 瀏覽:830
excel加密方法保護表格 瀏覽:193
今買明賣的選股公式源碼 瀏覽:215
騰訊手機加密的照片怎麼還原 瀏覽:547
飛利浦電視怎麼安裝APP 瀏覽:34