xml layout

  • 3 Antworten
  • Letztes Antwortdatum
M

moodsx

Neues Mitglied
0
Hallo Leute,

ich möchte dass, das imageview das Bild immer über die gesammt Bildbreite und Höhe anzeigt, jedenfalls so, wo genug Platz ist, nur mit meinem jetzigen layout wird es noch nicht mal in originaler Größe angezeigt. Hier mein Versuch:

Code:
          <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:background="@color/gray" >

        <TableRow>
            <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:textSize="@dimen/txt_width" />
        </TableRow>

		<TableRow
		    android:layout_width="fill_parent"
		    android:layout_height="fill_parent"
		    android:orientation="horizontal" >

			<ImageView
			    xmlns:android="http://schemas.android.com/apk/res/android"
			    android:id="@+id/imageview"
			    android:layout_width="fill_parent"
			    android:layout_height="fill_parent"
			    android:layout_gravity="center_vertical|center_horizontal"
			    android:background="@color/gray"
			    android:clickable="true"
			    android:onClick="reload"
			    android:scaleType="fitXY"
			    android:scrollbarAlwaysDrawVerticalTrack="true"
			    android:scrollbars="horizontal|vertical"
			    android:visibility="visible" />

		</TableRow>
		</TableLayout>

Wo liegt hier mein Fehler ?

Danke für Eure Hilfe
 
Was ist denn zu sehen?

Nichts? Dann könnte es evtl daran liegen das du die Orientierung auf vertikal gesetzt werden muss.

Ansonsten versuch es mit dem relativelayout anstatt des tablelayouts.
Mit dem geht fast alles

Gesendet von meinem HTC One X mit Tapatalk 2
 
Das image wird angezeigt und ist oben links, aber immer noch nicht in der original Größe.

Der ursprüngliche Beitrag von 18:15 Uhr wurde um 18:25 Uhr ergänzt:

Habe es jetzt angepasst, das imagview macht nun genau das was es soll. Leider sehe ich jetzt das TextView nicht mehr.

Hier mal der code dazu:

Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/gray"
            android:padding="5dp"
            android:textSize="@dimen/txt_width" />

			<ImageView
			    xmlns:android="http://schemas.android.com/apk/res/android"
			    android:id="@+id/imageview"
			    android:layout_width="fill_parent"
			    android:layout_height="fill_parent"
			    android:layout_gravity="center_vertical|center_horizontal"
			    android:background="@color/gray"
			    android:clickable="true"
			    android:onClick="reload"
			    android:scaleType="fitXY"
			    android:scrollbarAlwaysDrawVerticalTrack="true"
			    android:scrollbars="horizontal|vertical"
			    android:visibility="visible" />
        
    </RelativeLayout>
 
Versuchs ma hiermit:

Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/gray"
        android:padding="5dp"
        android:textSize="@dimen/txt_width" />

    <ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/imageview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/name"
        android:layout_gravity="center_vertical|center_horizontal"
        android:background="@color/gray"
        android:clickable="true"
        android:onClick="reload"
        android:scaleType="centerInside"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="horizontal|vertical"
        android:visibility="visible" />

</RelativeLayout>
Gruß
Jens
 
Zuletzt bearbeitet:
Zurück
Oben Unten