cuốn sách gpt4 ai đã làm

Thêm một TextView khác làm TextView thứ hai trong TextView trước đó

In lại Tác giả: Vũ trụ không gian Thời gian cập nhật: 2023-11-04 15:18:28 28 4
mua khóa gpt4 Nike

Các bạn ơi, tôi đã cố gắng thêm một TextView khác nhưng khi tôi thử thì TextView mới đã được đặt trên TextView trước đó, làm cách nào để thả TextView thứ hai thành TextView thứ hai mới

Đây là mã của tôi, hy vọng bạn có thể giúp tôi


android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >


android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:trọng lực="center_vertical"
android:text="@string/state1"
android:textSize="16sp" />



android:id="@+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@id/textView1"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/sayer1"
android:textSize="12sp" />



android:id="@+id/thirdLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@id/textView2"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/sayer2"
android:textSize="12sp" />


android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:trọng lực="center_vertical"
android:text="@string/state2"
android:textSize="16sp" />


câu trả lời hay nhất

Đơn giản, chỉ cần bọc hai TextView bằng LinearLayout và căn chỉnh chúng một chút.

Điều này sẽ rất gọn gàng thay vì chỉ định vị trong một bố cục tương đối. Vì nếu bạn muốn di chuyển thì toàn bộ TextView sẽ di chuyển cùng nhau. Vì vậy bạn không cần phải lo lắng về việc căn chỉnh từng TextView


android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical" >


android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/state1"
android:textSize="16sp" />



android:id="@+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_below="@id/textView1"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/sayer1"
android:textSize="12sp" />



Về java - Thêm một TextView khác làm TextView thứ hai trong TextView trước đó, chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/20661689/

28 4 0
không gian vũ trụ
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress