【发布时间】:2017-09-30 04:17:33
【问题描述】:
我有一个 xml 屏幕,在垂直方向的父线性布局中具有三个子线性布局。第一个孩子包含一个图像视图,运行应用程序时我无法查看任何图像。为什么?图片是不是太大了??如果是这样..如何扩展它?但是图像可以在我的设计选项卡中查看。的安卓标准。下面是我的 xml 文件的完整代码。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_sign_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.root.my_laoder.SignUp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="@drawable/ty"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="50dp"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp"
>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
/>
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
在您的 ImageView 中为
wrap_content执行height and width。 -
我做到了,我也尝试过 scaletype 检查我编辑的代码。没有结果:(
-
如果您可以提供快照,对我来说会更容易。此外,为了使您的图像居中,您必须将
android:gravity="centre_vertical|centre_horizontal"放在包含 imageview 的线性布局中 -
更改图像有效吗?或不同的比例类型(fitCenter)?尝试将 imageView 高度更改为 wrap_content (如果不是,您会将其余视图推出屏幕)
-
imagebin.ca/v/3L6C3tyxYASY @jack jay 我已经向您展示了设计选项卡。我不知道为什么我的移动应用程序显示的是空白而不是这个标志。
标签: android xml android-imageview image-scaling