【问题标题】:how to decrease height of linearlayout which is an image in android如何降低线性布局的高度,这是android中的图像
【发布时间】:2013-05-07 05:48:54
【问题描述】:

我想降低在 android 中用作线性布局的图像的高度。我该怎么做?我的代码如下:

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

<ImageView android:id="@+id/icon"
    android:layout_weight="0.15"
    android:layout_width="0dp"
    android:layout_height="48dp"
    android:layout_gravity="center_vertical"
    android:padding="5dp"
    android:scaleType="fitCenter"/>

<LinearLayout android:id="@+id/details" 
    android:layout_weight="0.75"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:gravity="center_vertical">

    <TextView
        android:id="@+id/primary_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:ellipsize="end"
        android:textSize="20dp"/>
</LinearLayout> 

<ImageView
   android:id="@+id/status"
   android:layout_width="50dp"
   android:layout_height="62dp"
   android:layout_gravity="center_vertical"
   android:layout_marginRight="7dp"
   android:layout_weight="0.08" />        

降低 imageview 的高度不起作用。我该怎么做?

【问题讨论】:

  • android:layout_height="100dp" 把它改成 `android:layout_height="wrap_content", 可以用吗
  • android:layout_height="fill_parent" 改成 android:layout_height="match_parent"
  • match_parent 也不起作用。

标签: android sentry


【解决方案1】:

减少 layout_height 或从图形布局手动减少它。如果即使它不起作用,那么您必须检查该图像的布局是否与其他图像重叠。如果是,则减小该布局的大小。

【讨论】:

    【解决方案2】:

    更改此标签中的高度 >> android:layout_height="100dp" ,使用更少的高度数字(80dp)或使其成为 wrap_content

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent">
    

    【讨论】:

      猜你喜欢
      • 2012-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-07
      • 2021-05-03
      • 1970-01-01
      • 2012-07-22
      • 1970-01-01
      相关资源
      最近更新 更多