LaybelLayout
???????????????????
?????? http://www.jianshu.com/p/82f0053b8726
##???? ?Projectd?gradle????????
maven {
url 'https://jitpack.io'
}
????Module??????
compile 'com.github.paulyung541:LaybelLayout:v1.2.0'
??????
app:line_padding="Integer" <!-- ??????????? --> app:text_background="reference" <!-- ??TextView?????? -->
??
?xml???????
<com.paulyung.laybellayout.LaybelLayout
android:id="@+id/laybel_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
app:text_background="@drawable/custom_back"
app:line_padding="5"/>
??Adapter????
Note? ??Adapter???ListView?Adapter????????????????
laybelLayout = (LaybelLayout) findViewById(R.id.laybel_layout);
laybelLayout.setAdapter(new LaybelLayout.Adapter(Content.content));
????????View???ImageView?????? Adapter.getView()
??
laybelLayout = (LaybelLayout) findViewById(R.id.laybelLayout);
laybelLayout.setAdapter(new LaybelLayout.Adapter(Content.images) {
@Override
public View getView() {
ImageView imageView = new ImageView(ImageActivity.this);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(getWidth() / 3, getWidth() / 3);
imageView.setLayoutParams(params);
return imageView;
}
@Override
public void onDataSet(View v, String data) {
Glide.with(ImageActivity.this).load(data).into((ImageView) v);
}
}
);
??????
laybelLayout.setOnItemClickListener(new LaybelLayout.OnItemClickListener() {
@Override
public void onItemClick(int p) {
Toast.makeText(DefaultTextViewActivity.this, Content.content[p], Toast.LENGTH_SHORT).show();
}
}
);