我試圖使用xml分割屏幕。代碼爲 請嘗試此xml ..我需要使用相同的編程方式。如何在不使用xml的情況下在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" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:background="@android:color/holo_purple">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" android:background="@android:color/holo_purple">
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:background="@android:color/holo_blue_dark">
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:background="@android:color/darker_gray">
</LinearLayout>
</LinearLayout>
</LinearLayout>
但是,我需要以編程方式分割屏幕。任何人都可以提供解決方案嗎?
是否有您所遇到的XML的特定部分在代碼中重新創建問題?你能提供迄今爲止所做的任何代碼嗎? – Matt
@ user2145222:看到這張圖..http://www.mediafire.com/view/myfiles/#m6l4q71av9x43h7我在xml中做過...但現在我需要它在編程方式在活動 –
抱歉,但不能回答我的的問題。我不會對你想要做的事情感到困惑,我只是想知道你在哪裏陷入困境。據推測,你至少有一些代碼來創建一些線性佈局? – Matt