ViewFlipper图像不被视为

在我的Android应用程序的活动之一,我有一个ViewFlipper里面坐了3个ImageViews,建这样的:ViewFlipper图像不被视为

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:context="com.example.app.MainActivity"

tools:showIn="@layout/app_bar_main"

android:layout_margin="8dp"

android:background="#fff">

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical">

<ViewFlipper

android:id="@+id/flipper"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

<ImageView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_gravity="center"

android:scaleType="center"

android:id="@+id/imageFlipper1"

android:adjustViewBounds="true" />

<ImageView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_gravity="center"

android:scaleType="center"

android:id="@+id/imageFlipper2"

android:adjustViewBounds="true" />

<ImageView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_gravity="center"

android:scaleType="center"

android:id="@+id/imageFlipper3"

android:adjustViewBounds="true" />

</ViewFlipper>

</LinearLayout>

</ScrollView>

我从网页加载图像使用滑行ImageViews使用此代码库(com.github.bumptech.glide:glide:3.7.0'):

flipper = (ViewFlipper) findViewById(R.id.flipper); 

imageFlipper1 = (ImageView) findViewById(R.id.imageFlipper1);

imageFlipper2 = (ImageView) findViewById(R.id.imageFlipper2);

imageFlipper3 = (ImageView) findViewById(R.id.imageFlipper3);

// Load images

Glide.with(getApplicationContext()).load("url1").into(imageFlipper1);

Glide.with(getApplicationContext()).load("url2").into(imageFlipper2);

Glide.with(getApplicationContext()).load("url3").into(imageFlipper3);

// Setup the ViewFlipper

flipper.setAutoStart(true);

flipper.setFlipInterval(2000);

flipper.startFlipping();

的网址是有效的,所以,当我试图将图像加载到一个独立的ImageView,只见屏幕上的图像。基本上什么都不应该包含错误,但由于某种原因,当我运行应用程序时,屏幕上看不到任何图像。

你能帮我一下吗?

回答:

我终于找到了解决方案。我改变了宽度和ViewFlippermatch_parentwrap_content的高度,内RelativeLayout S的match_parent的宽度和高度,现在我可以看到我的活动图像:

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:context="com.example.app.MainActivity"

tools:showIn="@layout/app_bar_main"

android:layout_margin="8dp"

android:background="#fff">

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical">

<ViewFlipper

android:id="@+id/flipper"

android:layout_width="match_parent"

android:layout_height="wrap_content">

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_gravity="center"

android:gravity="center">

<ImageView

android:id="@+id/flipper1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:adjustViewBounds="true"

android:foregroundGravity="center"

android:scaleType="fitCenter"/>

</RelativeLayout>

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_gravity="center"

android:gravity="center">

<ImageView

android:id="@+id/flipper2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:adjustViewBounds="true"

android:foregroundGravity="center"

android:scaleType="fitCenter"/>

</RelativeLayout>

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_gravity="center"

android:gravity="center">

<ImageView

android:id="@+id/flipper3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:adjustViewBounds="true"

android:foregroundGravity="center"

android:scaleType="fitCenter"/>

</RelativeLayout>

</ViewFlipper>

</LinearLayout>

</ScrollView>

以上是 ViewFlipper图像不被视为 的全部内容, 来源链接: utcz.com/qa/257629.html

回到顶部