我有兩種佈局。第一個只有TextView
,第二個有下面的代碼。如何根據第二個佈局的特定視圖將一個佈局與另一個佈局合併?
我想合併這兩個佈局的方式,第一個佈局顯示前面提到的第二個佈局的id爲「arry」的TextView
。我使用FrameLayout
這樣做,但爲此我必須爲第一個佈局設置頂部邊距。
我不想這樣做,因爲第一個佈局會根據屏幕大小的變化而上下移動。任何人都可以告訴我如何在不設置這種邊界的情況下做到這一點?我想獲得TextView
的位置,之後我想以編程方式設置第一個佈局。這裏是上述代碼:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.user_17.hashmapbasics.MainActivity">
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="@+id/arry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="@+id/arry1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
你能告訴我怎麼做同樣的務實? –
看看[this](http://stackoverflow.com/a/6917818/6950238)answer –