【问题标题】:Layout problem in Android Studio, but not in Eclipse?Android Studio 中的布局问题,但在 Eclipse 中没有?
【发布时间】:2019-02-25 00:24:31
【问题描述】:

我刚刚从 Eclipse 迁移到 Android Studio,我遇到了以下 xml 布局的问题。请注意,它在 Eclipse 中完美无缺。

<LinearLayout
android:id="@+id/tabview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2" >
<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"> 
   <TableRow
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weightSum="1"
        android:layout_weight="0.5">
        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:clickable="true" >
            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/btnKnowledge"
                android:background="@drawable/right_buttom_btn_line"
                android:text="@string/learn"
                android:textAllCaps="false"
                android:textSize="18sp"
                android:gravity="center|bottom"
                android:singleLine="false"
                android:paddingBottom="10dp"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/h_know"
                android:layout_centerInParent="true"/>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5">
            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/btnDictionaryManager"
                android:background="@drawable/right_buttom_btn_line"
                android:text="@string/csdl_"
                android:textSize="18sp"
                android:textAllCaps="false"
                android:gravity="center|bottom"
                android:singleLine="false"
                android:paddingBottom="10dp"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/dic_db2" 
                android:layout_centerInParent="true"/>
        </RelativeLayout>
    </TableRow>
</TableLayout>
</LinearLayout> 

此布局在 Eclipse 中按预期正确显示,但在 Android Studio 中,中间的图像丢失。

有什么问题?如何解决? 帮助表示赞赏。

【问题讨论】:

  • 尝试干净的构建并运行,然后看不到尝试无效并重新启动。在我的工作室中,这个布局文件可以正常工作。

标签: eclipse android-layout android-studio


【解决方案1】:

您的ImageViews 可能被按钮隐藏了。为您的ImageViews 添加一个小高度 - 类似于2dp。您可能会发现 Eclipse 设置和 Android Studio 之间的 API 级别有所不同(猜测)。

【讨论】:

    猜你喜欢
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-05
    • 1970-01-01
    • 2011-06-09
    相关资源
    最近更新 更多