我是Android新手,我試圖使用Android在屏幕的特定區域放置文本視圖。目前,textview覆蓋整個屏幕。我需要將它限制在特定的中央部分。請參見下面的截圖(我需要的TextView的框架是白方):佈局Android TextView相對於屏幕
這是我目前使用的代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:background="@drawable/help"
android:gravity="left"
android:layout_weight="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scrollbars = "vertical"
android:layout_weight="0.60"
android:textSize="14sp"
android:textStyle="bold"
android:id="@+id/text"/>
</LinearLayout>
我試過幾件事情我不能讓它工作,任何人都可以指出我要去哪裏錯了?
看來我應該使用LinearLayout來將我的視圖設置爲一定比例的屏幕,但我不確定這是否是正確的方法?
編輯:雖然我已標記爲正確的答案基本上是做正確的事情,如果你要創建的具體佈局,像這樣的,你需要爲每個不同的屏幕尺寸創建不同的佈局文件(一般爲小,中,大和大)。這些將被放置在項目的res文件夾中。
設置lineat佈局重心center_vertical和center_horizontal並給你的textview留下餘量。 –
創建自定義文本視圖。 http://stackoverflow.com/questions/11293866/how-to-have-a-circular-textview – Hemant