0
我试图创建这个接口:Android界面问题
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/displayGenericDialog"
android:weightSum="1"
android:background="#99000000"
android:layout_marginBottom="20dp"
android:layout_marginLeft="250dp"
android:layout_marginRight="250dp"
android:layout_marginTop="20dp">
<LinearLayout
android:id="@+id/displayMessageTop"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.15"
android:orientation="horizontal"
android:weightSum="100">
<TextView
android:id="@+id/textMessageTitle"
android:layout_width="910dp"
android:layout_height="match_parent"
android:layout_weight="90"
android:gravity="center|left"
android:paddingLeft="100sp"
android:textColor="#ffffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/displayMessageCenter"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.58"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/textMessageText"
android:layout_width="0px"
android:layout_height="492dp"
android:layout_weight="1"
android:gravity="left|center"
android:paddingLeft="40sp"
android:paddingRight="40sp"
android:textColor="#ffffffff" />
<ImageView
android:id="@+id/messagePicture"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:visibility="gone"
android:background="@drawable/image_view_border"
android:layout_margin="70sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/displayMessageBottom"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.11"
android:weightSum="1"
android:orientation="horizontal">
<ImageButton
android:id="@+id/sendResponseIB"
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="@drawable/panel_x"
android:gravity="center"
android:layout_weight="0.1"
android:onClick="closeProtip" />
<TextView
android:id="@+id/leftTextGenericDialog"
android:layout_width="0px"
android:layout_height="match_parent"
android:paddingLeft="10sp"
android:layout_weight="0.4"
android:clickable="true"
android:textColor="#ff72CCCC"
android:layout_marginTop="20dp"
android:gravity="center"/>
<ImageButton
android:id="@+id/rightPictureGenericDialog"
android:layout_width="0px"
android:layout_height="wrap_content"
android:paddingTop="5sp"
android:layout_weight="0.1"
android:background="@drawable/panel_x"
android:onClick="closeP" />
</LinearLayout>
</LinearLayout>
背景设定编程,因为头颜色可以变动内容。 First TextView textMessageTitle
用于白色标题,并以编程方式设置为大小50和粗体。
第二个textMessageText
是字体大小40.如果显示的消息只包含文本而没有图像,则文本应居中,否则应该留下文本的一半和图像的右半部分。 我已经试过:
if(image)
TextView.setPadding(200, 0, 200, 0);
else
TextView.setPadding(20, 0, 20, 0);
下的TextView rightTextGenericDialog
是一个与Send response
文字和sendResponseIB
是对文本的左侧图像按钮。 TextView和Image按钮应该在中心位置进行排列,在中心线下方和下方应该是紧密的ImageButton。
问题是我的界面看起来不像应该。 我是Android编程新手,请您保持温柔。
你解决了这个问题吗?下面的答案是否有效? –
感谢您的回答! – Dana