【问题标题】:Change size of layout in Android Studio在 Android Studio 中更改布局的大小
【发布时间】:2020-02-01 15:00:13
【问题描述】:

我正在为CardView 制作布局,但我无法让布局本身的大小合适。 LinearLayout 大小合适,但 Android Studio 仍显示全屏大小。这是编码错误还是 Android Studio 错误? 我的代码是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:orientation="horizontal">
</LinearLayout>

我的 xml 预览是

使用tools:showIn后,卡片视图的LinearLayout根本没有显示

【问题讨论】:

  • 问题只是在 Android Studio 布局预览中吗?您或许可以使用tools:showIn 属性来更改预览的绘制方式。
  • 它可能是。我试试看
  • 也添加您的 xml 预览的屏幕截图。
  • 我刚刚尝试了tools:showIn,它说“周围的布局 (@layout/new_ui_layout) 实际上并没有包含这个布局。从根标签中删除 tools:showIn=...。”
  • 这是仅在编辑器中出现的问题,还是在运行时出现的问题?

标签: android android-studio android-layout


【解决方案1】:

只需更改LinearLayoutorientation

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="100dp"
  android:orientation="vertical">
</LinearLayout>

【讨论】:

  • 我正在制作的布局使用水平 LinearLayout
猜你喜欢
  • 1970-01-01
  • 2012-08-30
  • 2019-06-09
  • 1970-01-01
  • 2011-10-18
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多