Ich habe eine Reihe von Gifs in verschiedenen Größen und ich möchte dann in einer horizontalen ListView ausrichten, so dass sie alle die gleiche Höhe haben, offensichtlich nicht unbedingt die gleiche Breite.Scale Gifs für eine horizontale ListView
Wir verwenden https://github.com/koral--/android-gif-drawable
Gif Anzeige xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:paddingLeft="10dp"
android:id="@+id/holder"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<pl.droidsonroids.gif.GifTextureView
android:layout_width="100dp"
android:id="@+id/gif_rec_view"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
Container
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/title1"
android:layout_marginTop="5dp"
android:background="@android:color/transparent"
android:id="@+id/xD">
<com.devsmart.android.ui.HorizontalListView
android:id="@+id/gif_search_1"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#e3e3e3"
/>
</RelativeLayout>
Last gif in Ansicht:
final GifTextureView textureView = (GifTextureView) convertView.findViewById(R.id.gif_rec_view);
LoadGif gLoad = new LoadGif(_objects.get(position).url, textureView);
gLoad.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[])null);
Wie würde ich das am besten lösen? Ausprobiert Haufen Zeug.
//textureView.setLayoutParams(new RelativeLayout.LayoutParams(_objects.get(position).width, _objects.get(position).height));
//RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
//params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
//textureView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
Edit 1:
Also auf diesen Thread suchen: How to scale an Image in ImageView to keep the aspect ratio
mit
android:adjustViewBounds="true"
android:scaleType="centerCrop"
Wunder gewirkt, aber die Bilder wie so abgeschnitten:
und
android:adjustViewBounds="true"
android:layout_centerInParent="true"
nicht bei allen.