简体   繁体   English

如何删除imageview上方和下方的多余空间?

[英]How do I remove extra space above and below the imageview?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/light_grey"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/program_title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal|center"
        android:gravity="center"
        android:padding="@dimen/borders"
        android:shadowColor="@color/light_grey"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/banner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/entertainment" />

    <TextView
        android:id="@+id/program_description"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:padding="@dimen/borders"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/program_times"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:padding="@dimen/borders"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />

    <Button
        android:id="@+id/program_episodes"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="WATCH EPISODES" />

    <Button
        android:id="@+id/program_calendar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="ADD TO CALENDAR" />

</LinearLayout>    

here is my code when i run this it shows extra space above and below the imageview i'm stuck in this how to remove it. 这是我的代码,当我运行它时,它在imageview上方和下方显示了额外的空间,我被困在此如何删除中。 It shows perfect on eclipse layout graphical view but shows extra space in emulator and android phone. 它在Eclipse布局图形视图中显示完美,但在模拟器和Android手机中显示了额外的空间。

Notice that your TextView's below and above the ImageView has padding: 请注意,ImageView下方和上方的TextView具有填充:

android:padding="@dimen/borders"

try it without the padding, also notice that you image source might contain padding itself 尝试不使用填充的情况,还要注意您的图像源可能包含填充本身

加:

android:adjustViewBounds="true"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM