Android Day02
by 木石溪
要點
- 問題五:安卓佈局的幾種方式;
- 問題六:關於EditText組件提示missing accessibility label;
- 問題七:關於Button組件提示Buttons in button bars should be borderless;
問題五
安卓的佈局方式
- 線性佈局 LinearLayout
- 相對佈局 RelativeLayout
- 絕對佈局 AbsoluteLayout
- 幀佈局 FrameLayout
- 表格佈局 TableLayout
- 約束佈局 ConstraintLayout
問題六
**MISSING ACCESSIBILITY LABEL: WHERE MINSDK < 17, YOU SHOULD PROVIDE AN ‘ANDROID:HINT’ **
在佈局文件(默認爲main_activity.xml)添加
xmlns:tools="http://schemas.android.com/tools" tools:ignore="LabelFor"
問題七
Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent)
在button中添加:
style="?android:buttonStyle"
注意:
buttonStyl爲按鍵佈局的一種,可以換爲其他的
問題八
針對當targetSdkVersion > 23時FileUriExposedException問題
問題描述:
android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/test.jpg exposed beyond app through ClipData.Item.getUri()
解決方法://在onCreat()函數中添加 StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); builder.detectFileUriExposure();