[英]Adding TextView with padding depending on another TextView
作為Android的初學者,我正在嘗試顯示一棵樹。 我已經找到了如何以編程方式添加新的TextView,但是我不知道如何放置它們,我的意思是如何根據父節點設置其填充/邊距。
非常感謝你的回答,
巴蒂斯特
親愛的,首先使用相對布局作為父對象,然后添加文本視圖child。i沒有添加相對布局,而是將相對布局作為父對象。
<TextView
android:id="@+id/txttxt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="node"
android:textColor="@color/white"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/txttxt12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_below="@+id/txttxt1"
android:text="Child"
android:textColor="@color/white"
android:layout_alignLeft="@id/txttxt1"/>
這是我為您制作的示例代碼。 您可以根據需要使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.