android Image resize in listview

Habe ich eine Bildansicht in einem relativen layout beide mit folgenden Eigenschaften android:layout_width="wrap_content" android:layout_height="wrap_content"

android Image resize in listview

Fülle ich dieses layout in ein Listenelement innerhalb einer mainactivity mit Hilfe eines Adapters. Dann ich versuchen, die Größe in Adapter mit dem code unten;

DisplayMetrics dm = new DisplayMetrics(); dm = ctx .getResources().getDisplayMetrics(); int width = dm.widthPixels; int height = width * 243 / 325;

          RelativeLayout.LayoutParams layoutParams = new

RelativeLayout.LayoutParams(width, height); thumbImage.setLayoutParams(layoutParams);

Aber die Bilder stecken in der listview-Element sogar kleiner als Ihre ursprüngliche Größe.

xml enthält Bildansicht, die gefüllt ist in-Adapter ist,

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="0dp">

<TextView
    android:id="@+id/tvKategori"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"

/>

<ImageView
    android:id="@+id/ivThumbnail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false" />

<TextView
    android:id="@+id/tvTitle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
     />

</relativelayout> 

- Und dies ist die mainactivity xml, das die listview und ich füllen lvGununVideolari listview und lvEnCokIzlenenler Inhalt.

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent">

<!-- Framelayout to display Fragments -->
<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

/>

<!-- Listview to display slider menu -->
<ExpandableListView
    android:id="@+id/list_slidermenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@color/list_divider"
    android:dividerHeight="1dp"        
    android:listSelector="@drawable/list_selector"
    android:background="@color/list_background"/>

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="0px"
android:paddingLeft="0px"
android:paddingRight="0px"
android:paddingTop="0px" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingBottom="0px"
    android:paddingLeft="0px"
    android:paddingRight="0px"
    android:paddingTop="0px"
    android:weightSum="1.0" >

    <Button
        android:id="@+id/btnGununVideolari"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight=".5"
        android:text="Günün Videoları"
        android:textSize="12sp" />

    <Button
        android:id="@+id/btnEnCokIzlenenler"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight=".5"
        android:text="En Çok İzlenenler"
        android:textSize="12sp" />
</LinearLayout>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ListView
        android:id="@+id/lvGununVideolari"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="0px"
        android:paddingLeft="0px"
        android:paddingRight="0px"
        android:paddingTop="0px" >
    </ListView>

    <ListView
        android:id="@+id/lvEnCokIzlenenler"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:paddingBottom="0px"
        android:paddingLeft="0px"
        android:paddingRight="0px"
        android:paddingTop="0px" >

    </ListView>
</RelativeLayout>

</linearlayout> </android.support.v4.widget.drawerlayout> 
InformationsquelleAutor onder | 2014-02-05
Schreibe einen Kommentar