【发布时间】:2014-09-14 10:02:37
【问题描述】:
所以,我有 Framelayout 女巫有 SurfaceView(0) 和 xml 布局(1)。我的布局高度是 200px(下),我正在绘制 200px 高的矩形进行测试。出于某种奇怪的原因,布局似乎占用了更多的空间棕褐色矩形。无论屏幕大小或密度如何,我怎么能做到这一点,布局将是矩形? (我希望这不会太混乱......)
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="200px"
android:orientation="horizontal"
android:id="@+id/game_ui
"
style="@style/AppTheme">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:text="Points"
android:textSize="30sp"
android:gravity="center"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:text="500"
android:textSize="60sp"
android:gravity="center"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:text="Time"
android:textSize="30sp"
android:gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:text="500"
android:textSize="60sp"
android:gravity="center"/>
</LinearLayout>
画一个矩形:
Graphics g = game.getGraphics();
g.clearScreen(Color.BLACK);
g.drawRect(0, 0, wildth, 200, Color.GREEN);
//draws 200px high rectangle onto surfaceView
结果是这样的:
【问题讨论】:
标签: java android xml android-linearlayout surfaceview