導航:首頁 > 操作系統 > android輸入框邊框

android輸入框邊框

發布時間:2022-08-22 09:47:29

1. 怎麼給android 設置邊框

Android是一種基於Linux的自由及開放源代碼的操作系統,主要使用於移動設備,如智能手機和平板電腦。Android在開發過程中,很多情況下需要我們在TextView上面添加一個邊框,但是TextView本身不支持邊框,這里介紹幾種設置邊框的方法,可以供大家參考:

2. 怎麼給android 設置邊框

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

3. Android studio3.0版本layout編輯顯示界面,怎麼設置手機邊框

1.我們知道很多時候編輯框用來輸入一行字元的時候會在下方有一條直線,此時是很美觀的,但是如果要輸入很長一段文字的文本編輯框時,一條橫線就有失美觀了,那麼我們需要加上一個語句,讓他有一個邊框
android:background= "@android:drawable/edit_text"
2.inputType關於這個呢就是說你在游標點到編輯框裡面的時候,手機會彈出來一個軟鍵盤就是虛擬鍵盤,用來我們的輸入,那這個其實就是,我理解哈,給用戶更好的體驗,像是意見啊之類的他肯定是全鍵盤或是九鍵盤可以輸入字元的,那麼對於輸入手機號或是一串數字來說,那給他全鍵盤用戶還要調到數字鍵盤上去,但是如果你直接給他數字鍵盤,他的用戶體驗是不是更好呢?
number是數字鍵盤,其中numeric可以是小數可以是整數;text就是有字母的全鍵盤、九鍵盤了;還可以是phone,這個跟那個數字的就比較接近了

4. android中edittext控制項可以添加邊框嗎

可以。
1、將edittext的style設置成?android:attr/textViewStyle 取消掉默認的樣式,再設置background為@null
2、接下來就是一個空空的edittext了, 在兩個edittext中間加一個view,設置background為灰色,寬度match_parent,高度2dip。
代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/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>

5. android4.2開發怎樣讓文本框有邊框

方法一:

比較土 ,加背景圖片,透明的帶邊框的背景圖片
設置到android:background就可以

方法二:
android:background的值是一個xml文件

yle="font-family: mceinline;">TextView的xml:

<TextView android:id="@+id/roomInfo"
android:layout_centerHorizontal="true"
android:textSize="24dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentRight="true"
android:textColor="@color/solid_black"
android:background="@drawable/setbar_bg"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:layout_width="300dip">
</TextView>

setbar_bg.xml 放在drawable-hdpi文件夾下面

<?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>

6. 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>

7. 怎麼給android 設置邊框

給view設置邊框的代碼:

1.創建xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

2.設置<!-- 圓角 -->
<corners
android:radius="9dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"/><!-- 設置圓角半徑 -->

3.設置<!-- 漸變 -->
<gradient
android:startColor="@android:color/white"
android:centerColor="@android:color/black"
android:endColor="@android:color/black"
android:useLevel="true"
android:angle="45"
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="90"/>

4.設置<!-- 間隔 -->
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/><!-- 各方向的間隔 -->

5.設置大小精細<!-- 大小 -->
<size
android:width="50dp"
android:height="50dp"/><!-- 寬度和高度 -->

6.設置<!-- 填充 -->
<solid
android:color="@android:color/white"/><!-- 填充的顏色 -->

7.設置邊框<!-- 描邊 -->
<stroke
android:width="2dp"
android:color="@android:color/black"
android:dashWidth="1dp"
android:dashGap="2dp"/>
</shape>

8. android 如何讓edittext控制項顯示邊框

editText控制項,邊框其實是背景決定的,所以如果你的editText沒有邊框,可以通過以下兩種方式解決:

  1. 給editText設置一個帶邊框的背景,可以是shape繪制一個corner和solid,也可以是用一個切好的.9圖。

  2. 你應該是用的主題不對,把application的主題改成android:Theme.Light.NoTitleBar,editText的樣式應該是有邊框的那種了。

9. 怎麼給android 設置邊框

  1. android設置邊框利用內容的margin或者padding的留白加容器的背景來實現邊框效果。

  2. shape來實現邊框效果

  3. corners是設置邊框圓角

  4. stroke是描邊的

  5. layer-list實現自由邊框

嵌套一層,利用內容的margin或者padding的留白加容器的背景來實現邊框效果。其實這個道理很簡單,很早的時候那時候我們還用table做html頁面布局的時候,我們就是使用cellspacing來實現table的邊框的。現在我們也利用同樣的想法來實現。

當然內部的容器也是需要有顏色的,如果想實現內部透明的效果則需要將內部View的背景色跟背景的顏色保持一致,這是不太方便的地方。


在Android中,給一個控制項(或View)設置背景主要是通過background:xxx屬性來完成。background的參數一般來說是一個drawable資源。


給控制項設置邊框最簡單的方式就是把background設置成你預先設計好的帶圓角和邊框的背景圖。但是這種方法的缺點是沒有靈活性,不同大小的view要不同尺寸的圖片,還要去適應不同解析度的設備。


3使用9-patch(九宮格)的背景圖片來實現邊框效果。


做一個有邊框的9-patch圖片,作為要有邊框的View的背景圖即可。這樣你還可以控制哪邊有邊框,哪邊無邊框,這種方法是比較好的一種方法,而且沒有多餘的View嵌套。另外你還可以實現圓角邊框等效果。


4利用shape來實現邊框效果。


當然你可以使用shape中的stroke來實現border的效果。


/res/drawable/filename.xml


只要引用這個shape作為背景圖片即可。


5.layer-list實現自由邊框

當前版本的Android

SDK並沒有給stroke提供bottom、left、right之類的屬性,也就是說你無法通過它來讓長方形的邊框少於4條。於是有人想出了這個方法。


android:width="1dp"


android:color="#333"/>


android:left="1dp"


android:top="1dp"


android:right="1dp"


android:bottom="1dp">


android:color="#FFF"/>


在第二個item中定義的top,left...就是對應的邊框,不設置即沒有邊框。

閱讀全文

與android輸入框邊框相關的資料

熱點內容
朴超賢電影都有哪些 瀏覽:122
電影大區 瀏覽:479
阿里方舟編譯 瀏覽:229
華為光貓命令注冊和自動注冊區別 瀏覽:331
linuxcv 瀏覽:926
玩具程序員 瀏覽:67
好多兔子的電影叫什麼 瀏覽:545
天仙配紅羊電影 瀏覽:38
壓縮軟體winrar64位 瀏覽:942
武漢市農科院伺服器地址 瀏覽:101
androidtextview邊框線 瀏覽:217
邵氏古裝鬼片大全 瀏覽:757
最全的武俠小說打包下載 瀏覽:775
冷鏈食品配備源碼 瀏覽:327
蘋果相片簿加密 瀏覽:816
農行app繳的保險如何查信息 瀏覽:317
韓劇女主在自家鋼琴讓男生摸她胸 瀏覽:674
兩個字的中國電影 瀏覽:755
顧傾城女主的小說 瀏覽:943
觸摸屏編程cd和dc的區別 瀏覽:910