2013-10-20 17 views
0

之間的區別我是Android應用程序開發的新手。android:layout_property和android:屬性

我想知道是什麼規定android:layout_somepropertyandroid:someproperty之間的差異。例如android:layout_heightandroid:height

我的Eclipse上懸停提供以下信息

android:layout_height : Specifies the basic height of the view.[dimension.enum] 
android:height : Makes the TextView exactly this many pixel tall[dimention] 

但我不明白這一點。我的代碼是一樣的東西

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/mainscreen_background" 
    android:layout_gravity="center" 
    android:padding="30dip" 
    android:orientation="vertical" 
    tools:context=".TicTacToe" > 

    <TextView 
     android:text="@string/game_title" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_marginBottom="25dip" 
     android:layout_gravity="center" 
     android:textSize="24.5sp"/> 
</LinearLayout> 

情理之中的事情,並沒有各有什麼影響?

  1. 設置android:layout_heightLinerLayout標記。
  2. 設置android:layout_heightTextView標記。
  3. LinerLayout標籤設置android:height
  4. TextView標籤設置android:height

至於我的理解去LinearLayout將是TextView(糾正我,如果我錯了)的母公司。

回答

0

好,設置layout_height其實並不是一個視圖的屬性,但其sourrounding佈局。 android:height,設置Views高度。

一般使用layout_height並儘量避免任何形式的絕對值,因爲這會不會看上去很怪不同寬高比/尺寸屏幕

你必須設置機器人:在兩者的TextView和LinearLayout中layout_height 。

,如果這是你的整個片段,我會設置root的觀點在兩個維度來match_parent,而且通常你設置的子視圖layout_height包裹內容和layout_width匹配父。

這將創建一個佔據他的父母的整個寬度一個TextView,並適應其內容的大小。