日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

Android studio的UI组件

發(fā)布時(shí)間:2024/7/23 Android 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android studio的UI组件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.文本框組件

?掌管文字大小,文字來(lái)源,文字是否以行的形式顯示,對(duì)齊方式居中

9patch圖片拉伸不變形,需要放在drawable中

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="30dp"android:text="@string/demo1"android:singleLine="true"android:gravity="center"/>

?

2.編輯框組件

掌管一些可輸入的文字框,這里可以給用戶提供輸入

<EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:hint="請(qǐng)輸入密碼"android:inputType="numberPassword"/>

?在編輯框內(nèi)繪制圖像屬性:(相對(duì)于文字的方向)

android:drawableLeft=""左側(cè)android:drawableStart=""左側(cè)android:drawableBottom=""底部android:drawableRight=""右側(cè)android:drawableEnd=""右側(cè)android:drawableTop=""頂部 搭配android:drawablePadding=""配合內(nèi)邊距

3.普通按鈕組件

文字按鈕:很簡(jiǎn)單,和上面組件的屬性差不多,一樣是設(shè)置寬高,設(shè)置text文本內(nèi)容<Button>

圖片按鈕:區(qū)別如下<ImageButton/>

android:src="@資源名字"

單選按鈕:可以設(shè)置單選的內(nèi)容,checked是默認(rèn)選中的意思

<RadioButtonandroid:id="@+id/rb_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn2"android:text="男"android:checked="true"/>

有時(shí)候不止一個(gè)單選按鈕,所以就需要單選按鈕組的出現(xiàn)<RadioGroup><RadioButton>......</RadioGroup>

<RadioGroupandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn2"><RadioButtonandroid:id="@+id/rb_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="男"android:checked="true"/><RadioButtonandroid:id="@+id/rb_2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="女"/></RadioGroup>

設(shè)置組的java監(jiān)聽器,點(diǎn)擊男的單選框會(huì)顯示男,點(diǎn)擊女的單選框會(huì)顯示女

RadioGroup rg= (RadioGroup) findViewById(R.id.rg_1);rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {RadioButton rb= (RadioButton) findViewById(checkedId);rb.getText();Toast.makeText(DemoMainActivity.this, "性別:"+rb.getText(), Toast.LENGTH_SHORT).show();}});

?復(fù)選框按鈕:

<CheckBoxandroid:id="@+id/cb_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="人類"android:layout_below="@+id/bt3"/><CheckBoxandroid:id="@+id/cb_2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="人"android:layout_below="@+id/cb_1"/><CheckBoxandroid:id="@+id/cb_3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="類"android:layout_below="@+id/cb_2"/>

?

?

?

總結(jié)

以上是生活随笔為你收集整理的Android studio的UI组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。