Wie Lesen Bildansicht-Marge programmgesteuert?

Ich habe eine Bildansicht, die ist geschrieben in einer layout-Datei und sieht wie folgt aus

<LinearLayout 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">

        <ImageView android:id="@+id/news_image" 
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:layout_marginLeft="18dip"
            android:layout_marginRight="18dip"
            android:background="#aaaaaa" />

</LinearLayout>

Wie kann ich Lesen Sie die android -: layout_marginLeft Attribut in meine Tätigkeit?

Habe ich versucht, diese folgenden code, der aber LayoutParams meiner ImageView keine margin-Mitglieder (wie zum Beispiel LinearLayout.LayoutParams hat).

ImageView imageView = (ImageView)findViewById(R.id.news_image);
LayoutParams lp = imageView.getLayoutParams();

int marginLeft = lp.marginLeft; //DON'T do this! It will not work 
                                //cause there is no member called marginLeft

Irgendwelche Vorschläge, wie man den Rand von einem ImageView?

Danke!

InformationsquelleAutor OemerA | 2011-02-03

Schreibe einen Kommentar