【发布时间】:2014-03-17 14:52:25
【问题描述】:
我有带有 TextView 和 Button 的 LinearLayout。我将 layout_height 属性设置为 wrap_content 但 layout_height 的尺寸要大得多。如果我删除此按钮,那么一切都很好。我尝试减小按钮文本大小,但按钮的框架仍然相同。我不想要硬编码按钮大小。这个奇怪的结果可能是什么原因?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/left_margin"
android:layout_marginTop="@dimen/top_margin"
android:layout_weight=".3"
android:text="@string/contact" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:layout_marginLeft="@dimen/left_margin"
android:layout_marginTop="@dimen/top_margin"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="@+id/contact"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/contact" android:textSize="@dimen/button_font_size"/>
</LinearLayout>
【问题讨论】:
标签: android android-layout button android-linearlayout