android文本邊框
1. 怎麼給android 設置邊框
1.首先在res目錄下新建一個xml文件,類型選擇drawable,將自動生一個一個drawable文件(我用的sdk是android 4.1),並生成一個xml文件,在其中寫入以下代碼:
[java] view plain
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFFFFF" />
<stroke
android:width="0.01dp"
android:color="#FFFFFF" />
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0.5dp"
android:top="0dp" />
</shape>
2.在要設置邊框的控制項xml命令里加入:android:background=「@drawable/boder」
2. android程序的輸入框四個邊都要顯示怎麼弄
在Android開發中,如果希望輸入框四個邊都顯示,首先需要了解默認情況下,輸入框會根據其類型和狀態顯示不同的邊框樣式。對於大多數輸入框,這種默認設置是滿足需求的。
然而,若需進一步自定義邊框樣式,可以通過設置控制項的style屬性來實現。在Android的XML布局文件中,可以為輸入框設置自定義的樣式資源。樣式資源可以在styles.xml文件中定義,然後在布局文件中引用。
具體步驟如下:首先,在res/values/styles.xml文件中定義一個新的樣式,設置輸入框邊框的寬度、顏色等屬性;然後,在XML布局文件中,為輸入框設置這個自定義的style屬性。例如:
<EditText android:style="@style/MyInputBorder"></EditText>
其中,「MyInputBorder」是自定義的樣式名稱,在styles.xml文件中定義如下:
<style name="MyInputBorder">
<item name="android:padding">10dp</item>
<item name="android:background">#FFFFFF</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:shape">rectangle</item>
<item name="android:strokeWidth">2dp</item>
<item name="android:strokeColor">#FF0000</item>
</style>
通過這種方式,可以確保輸入框四個邊都顯示,並且可以根據需求進行調整。值得注意的是,樣式定義和引用要保持一致,否則可能會出現樣式不生效的情況。
此外,還可以通過代碼動態設置輸入框的邊框樣式,例如通過設置View的setStrokeWidth和setStrokeColor方法。這種方法更加靈活,可以根據運行時的狀態動態調整邊框樣式。
總的來說,通過自定義樣式或者代碼動態設置,可以靈活控制Android輸入框的邊框顯示,滿足不同的界面設計需求。
3. Android設計規范 Material Design-Layout
Android設計規范Material Design中的Layout布局要點如下:
度量與邊框基準網格:
- 所有組件都與間隔為8dp的基準網格對齊。
- 排版/文字與間隔為4dp的基準網格對齊。
- 工具條中的圖標同樣與間隔為4dp的基準網格對齊。
邊框與間距:
- 移動設備布局模板包含多種屏幕和信息,描述了邊框與間距如何應用於屏幕邊界和元素。
- 左右各有16dp的垂直邊框,帶有圖標或頭像的內容有72dp的左邊距,移動設備上有16dp的水平外邊距。
- 垂直邊距根據不同的布局元素和設計需求,可能取值為24dp、56dp、48dp或72dp等。
觸摸目標尺寸:
- 最小的觸摸目標尺寸是48dp。
- 在布局中設置圖標或頭像的邊距時,需確保觸摸目標不重疊。
增量邊框:
- 增量邊框定義了一個增量,然後使用幾倍於這個增量的數字來決定應用中其它元素的尺寸和位置。
- 增量邊框主要應用於桌面應用程序,部分適用於平板設備,較少應用於移動設備。
屏幕寬度與元素寬度:
- 應用於移動設備屏幕的寬度和移動設備、平板設備以及桌面應用程序中UI元素的寬度,需根據具體的屏幕尺寸和設計規范進行調整。
布局模板:
- 移動設備、平板設備和桌面應用程序均有各自的布局模板,這些模板詳細展示了邊框和邊距如何應用於不同的屏幕和元素。
遵循這些規范可以確保Android應用在視覺上的一致性和用戶體驗的流暢性。
4. android怎麼讓gridview有邊框線
gridview有邊框線通過設置裡面控制項的backgroud,也就是邊框。通過shape設置。
下面例子來自於android學習手冊,android學習手冊包含9個章節,108個例子,源碼文檔隨便看,例子都是可交互,可運行, 源碼採用android studio目錄結構,高亮顯示代碼,文檔都採用文檔結構圖顯示,可以快速定位。360手機助手中下載,圖標上有貝殼。
<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android">
<!--圓角-->
<corners
android:radius="9dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"/><!--設置圓角半徑-->
<!--漸變-->
<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"/>
<!--間隔-->
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/><!--各方向的間隔-->
<!--大小-->
<size
android:width="50dp"
android:height="50dp"/><!--寬度和高度-->
<!--填充-->
<solid
android:color="@android:color/white"/><!--填充的顏色-->
<!--描邊-->
<stroke
android:width="2dp"
android:color="@android:color/black"
android:dashWidth="1dp"
android:dashGap="2dp"/>
</shape>
5. 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>