如何在“中动态更改视图边距”;Android Flowlayout“;
我有一个布局如何在“中动态更改视图边距”;Android Flowlayout“;,android,Android,我有一个布局hash\u tag\u布局 <org.apmem.tools.layouts.FlowLayout android:id="@+id/hash_tag_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" and
hash\u tag\u布局
<org.apmem.tools.layouts.FlowLayout
android:id="@+id/hash_tag_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/view_padding"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
</org.apmem.tools.layouts.FlowLayout>
所以,我不得不承认,布局不允许我向动态添加的视图添加页边距
你知道如何更改源代码或找到解决方法吗?可能在动态添加的视图周围添加一个透明边框?只需将
线性布局.LayoutParams
更改为FlowLayout.LayoutParams
是GitHub上的一个问题讨论
我知道你三年前问了一个问题,但我刚刚遇到了同样的问题:)只要将
线性布局.LayoutParams
更改为FlowLayout.LayoutParams
是GitHub上的一个问题讨论
我知道你三年前问了一个问题,但我刚刚遇到了同样的问题:)
int pixels = convertDensityPixelsToPixels(5);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(0,0,pixels,pixels); //<---<< This line has no effect
TextView tv1 = new TextView(ctx);
tv1.setPadding(pixels,pixels,pixels,pixels); //int left top right bottom
tv1.setBackground(ctx.getResources().getDrawable(R.drawable.hash_tag_bubble_format));//drawable
tv1.setText("# Asd");
tv1.setLayoutParams(lp);
layout.addView(tv1);
<LinearLayout
android:id="@+id/hash_tag_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>