android面試(1)----布局

來源:互聯網
上載者:User

標籤:

1.說出android 五中布局,並說出各自作用?

FrameLayout: 堆疊布局,也是就可以堆在一起。最長應用於Fragment的使用上。

LinearLayout: 線性布局,可以是豎排或水平。

ReleativeLayout:複雜頁面一般都會用到,可以通過相對位置,而忽略頁面的大小。

absolutlayout:絕對布局:固定x,y的座標。

Tablayout:用於標籤頁。

2.xmlns:android="http://schemas.android.com/apk/res/android"

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <Button        android:id="@+id/btn_start"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/start">    </Button></LinearLayout>

該屬性定義了android resource的命名空間。

3.linearlayout 分割線?

android 3.0以上支援分割線:

android:showDividerd.

4.如何確定按鈕在手機螢幕的位置?

View.getLocationOnScreen(location);

5.如何不用xml來布局releativeLayout中的view?

可以使用layoutparamters來通過layoutparamters.addrule來設定。

6.Tablelayout如何使用?

Tablelayout 用tablerow來規定每一行,每一行的列數是可以不同的。

7. android:stretchColumns="2" 在tablelayout中

android:stretchColumns="2"表示第二列會撐滿剩下的空間。

 8.將布局存為映像!

view.setdrawingcacheenable(true);

view.getDrawingCache();

9.如何設定漸層背景?

色彩坡形的方向由GradientDrawable.Orientation定義可以有如下八種:

mDrawable =  new  GradientDrawable(GradientDrawable.Orientation.TL_BR, new  int [] {  0xFFFF0000 0xFF00FF00 , 0xFF0000FF  });分別使用Liner,Radial 和Sweep三種漸層模式,並配合指定矩形四個角圓角半徑,顯示GradientDrawable的不同用法: mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); setCornerRadii(mDrawable, r, r,  0 0 ); mDrawable.draw(canvas);10.android:layout_weight的作用?值越大,重要程度越低。如果layout_weight一個是1,一個是2,並且width和height都是match_parent則顯示2/3 and 1/311.dp & sp?160dpi = 320*48012.android:layout_gravity and android:gravity的區別?android:layout_gravity是指View在父控制項中的位置,而android:gravity是指內容的位置。12.如何重用布局檔案?<include android:id="+id/layout1" [email protected]/myloyout>13.merge的作用?merge會過濾掉多餘的布局外殼。14. 

android面試(1)----布局

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.