У меня есть ImageView, который записан в файле макета и выглядит примерно так
<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>
Как я могу прочитать атрибут android: layout_marginLeft в моем Activity ?
Я пробовал следующий код, но LayoutParams
моего ImageView
не имеет никаких элементов поля (например, LinearLayout.LayoutParams
имеет).
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
Есть предложения, как получить маржу из ImageView
?
Спасибо!