我在一排中有 4 个 ImageView ,但我想要可见,并且需要根据响应执行操作。那么如何删除我硬编码布局中未使用的空间。
<ImageView
android:id="@+id/imgFacebookUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/facebook_login_guest"
app:layout_anchor="@id/appbar"
android:visibility="gone"
app:layout_anchorGravity="bottom|center" />
<ImageView
android:id="@+id/imgLinkdinUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="200dp"
android:src="@drawable/icon_linkdin"
app:layout_anchor="@id/appbar"
android:visibility="gone"
app:layout_anchorGravity="bottom|center" />
最佳答案
public void setPadding (int left, int top, int right, int bottom)
Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom() may be different from the values set in this call.
终于
ImageView ImageViewObj = (ImageView) findViewById(R.id.imgLinkdinUrl);
ImageViewObj.setPadding(0, 0, 0, 0);
关于java - 如何在android中以编程方式删除 ImageView 周围的填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34850827/