簡體   English   中英

消息傳遞應用程序Android XML的布局問題

[英]Layout issue for messaging app Android XML

我正在嘗試在android中創建一個消息傳遞應用程序,並創建了一個自定義列表適配器,該適配器顯示消息文本以及日期。 我同時顯示了它們,現在希望它們能夠以某種方式顯示。 我希望能夠在屏幕的一側發送消息,而在另一側接收消息,並且日期顯示在消息文本的下方/側面

這是我用於列表中每個項目的自定義xml,任何有關如何適當包裝它們並移至屏幕兩側的想法都將不勝感激!

(注意:我嘗試將LinearLayouts與權重結合使用,將RelativeLayouts與android:layout_alignParentRight和其他東西結合使用,但由於無法獲得所需的確切信息,所以我想在這里問!)

(不要認為需要其他代碼段,但是可以根據需要提供!)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<TextView android:id="@+id/msgTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@android:color/black"
    android:paddingRight="2dp"
    android:textStyle="bold"
    android:textSize="15sp" />

<TextView android:id="@+id/msgDate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     />
</LinearLayout>

干杯

我試過使用權重的LinearLayouts

怎么了 android:layout_weight="0.4"

嘗試不使用“ fill_parent”,使用“ match_parent”;

另外,替換這個

android:textSize="15sp"

對此:

android:textAppearance="?android:attr/textAppearanceMedium"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM