I'm using paths as a strings in my SQLite database
, and I'm using Viewbinder
to adopt views to my expendablelistview
..the paths are turned images by glide library
..the problem i got is there is always space after the text even if there is no string(hence no image to show) ..what sould i do to hide that space if there is no path in my sqlitedatabase( case empty or null) .
PS1: The constraint layout groups 2 imagesviews and has a specific height(100dp) ..because if there is an image and i didn't fix the height of constraint layout(for exemple if used wrap_content) i get this problem(with layout_height of imageview as wrap_content also):
https://i.stack.imgur.com/Uxm28.png (too much space around the picture)
second case: if i put the constraint layout as wrap_content and images view with a fixed layout_height(90dp) ..things looks good but the image is blurry:
https://i.stack.imgur.com/wxWtx.png
To SUM UP: the imageview should keep height as wrap_content to not look blurry and the constraint layout_height should be fixed so i don't get too much space around the picture ..so the only solution for my matter is to hide the constraint layout that group the imagesview if there is no url in both of them in mysqlite database ..thanks a lot
PS: child2 and child3= the id of imageviews in xml file
exemple Code of child2 in xmlfile:
<android.support.constraint.ConstraintLayout
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/child1"
android:orientation="horizontal">
<ImageView
android:id="@+id/child2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
Code from activity.java:
case R.id.child2 :
ImageView url = (ImageView) view;
String urls;
urls = cursor.getString(cursor.getColumnIndex(Database.DATABASE_CHILD_2));
Glide.with(Nostrils.this).load(urls).apply(noTransformation()).into(url);
url.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder mBuilder = new AlertDialog.Builder(Nostrils.this);
View mView = getLayoutInflater().inflate(R.layout.dialog_custom_layout, null);
PhotoView photoView = mView.findViewById(R.id.imageView);
photoView.setImageDrawable(((ImageView)view).getDrawable());
mBuilder.setView(mView);
AlertDialog mDialog = mBuilder.create();
mDialog.show();
}
});
break;