由网友(冷了淡了心凉了)分享简介:我试图做一个虚线。我使用这个权利现在实线:I'm trying to make a dotted line. I'm using this right now for a solid line:LinearLayout divider = new LinearLayout( this );LinearLayout...
我试图做一个虚线。我使用这个权利现在实线:
I'm trying to make a dotted line. I'm using this right now for a solid line:
LinearLayout divider = new LinearLayout( this );
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 2 );
divider.setLayoutParams( params );
divider.setBackgroundColor( getResources().getColor( R.color.grey ) );
我需要这样的事情,但点缀而不是固体。我想避免一个透明的布局和扎实的布局之间做出上百种布局交替出现。
I need something like this, but dotted instead of solid. I'd like to avoid making hundreds of layouts alternating between a transparent layout and solid layout.
推荐答案
没有Java code:
Without java code:
绘制/ dotted.xml:
drawable/dotted.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#C7B299"
android:dashWidth="10px"
android:dashGap="10px"
android:width="1dp"/>
</shape>
view.xml用:
view.xml:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/dotted" />
相关推荐
最新文章