I have a circular image:
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/circularIcon"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/img_gr"
app:civ_border_color="#EEEEEE"
app:civ_border_width="1dp"
app:civ_shadow="true"
app:civ_shadow_radius="3"
android:layout_gravity="center_horizontal"
app:civ_shadow_color="#8C0F0F"
android:layout_weight="1"
android:visibility="visible"/>
And I want to add around it, something like a "frame":
https://i.stack.imgur.com/uadIp.png
so the frame would be exactly wrapping the circular image view
If you want to add a simple frame to your circular ImageView you can use this library CircleImageView
Related
I am using https://github.com/AleSpero/ExpandableCardView library to make an expendable card view. But i don't need the arrow placed in right side.
I also try to find for the attribute or method that can remove this but don't find any one. Please help me to solve this. I will be very grateful. Thanks in advance for your time.
card.setIcon(null);
but it remove only the left icon not the right icon.
Just add this lineandroid:groupIndicator="#null"
<ExpandableListView
android:id="#+id/ev_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="188dp"
android:background="#android:color/white"
android:dividerHeight="0dp"
android:groupIndicator="#null" />
On your MainActivity please use below code
val card : ImageButton = findViewById(R.id.card_arrow)
card.visibility=View.INVISIBL
or remove icon from this xml file expandable_cardview
<ImageButton
android:id="#+id/card_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_alignParentEnd="true"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="#string/expandable_card_view_image_content_description"/>
I have a gif image as
However using glide i do this
Glide.with(this)
.load(Uri.parse("file:///android_asset/" + "stickers/" + emoji))
.into(gifImage);
What i get is
Exactly what is going on, I have tried GifImageView library too and result is same. How can i parse gif image properly in android?
after adding datasource
<ImageView
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:visibility="gone"
android:layout_height="100dp"
android:layout_width="100dp"
android:id="#+id/chateeGifImage"
/>
try like this
Glide.with(con).load(url).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(ivImage);
I want to insert an image to an ImageView, which gets used as a background. This background is in a RecyclerView. When it gets loaded the first time, it looks like this:
But when I scroll to another item and scroll back, it looks like this (it should always look like this):
Here i add the image:
public void onBindViewHolder(StoryViewHolder holder, int position) {
holder.cardView.setMinimumHeight(height/3);
holder.layout.setMinimumHeight((int) ((float) width / 4));
//set image
Picasso.with(activity).load(MainPostAdapter.URL + 140 + ".png").
transform(new BlurTransform(holder.background.getContext())).fit().centerCrop().into(holder.background);
holder.background.setAlpha(0.25f);
}
And this is the image itself:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/story_view_background"/>
What could the problem be?
EDIT:
whole XML (It doesn't show all of the code. Here is also pastebin:http://pastebin.com/8rJvSx7V):
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/story_view_background"/>
<RelativeLayout
android:id="#+id/story_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="50px">
<ImageView
android:id="#+id/story_view_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/story_view_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="#+id/story_view_image"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</FrameLayout>
try to set android:layout_height="150dp" for your CardView (don't use px!). Its child FrameLayout is unnecesarry (CardView is extending FrameLayout and have set same attributes set), remove it.
It's not so well written, all your Views have match_parent set for height, besides Image and Text views... Your item is probably trying to fit RecyclerView height in this case ("whole screen") and is measured without image at first time (Picasso async downloading, setting image when view is already measured). But when you inflate your View again (scroll and recycle) new list item will be measured differently, because Picasso will insert your image "in runtime", no need to async fetching (cache)
I've been working on a simple java application, and wanted to add a logo as the homescreen is fairly empty. I tried using an image view, and after it didn't work I googled tutorials to make sure I was initiating it correctly. I didn't see any difference, but the actual image wouldn't load.
Xml code for image view:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src = "#drawable/logo"
android:layout_gravity="center"
android:contentDescription="#string/logo"
android:layout_below="#+id/textView"
android:layout_above="#+id/txtBody"
android:layout_alignRight="#+id/txtBody"
android:layout_alignEnd="#+id/txtBody"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="visible"
android:maxHeight="600dp"
android:maxWidth="600dp"
android:minHeight="100dp"
android:minWidth="100dp"
android:clickable="false" />
And here's a picture of the layout preview (With an arrow pointing to the outline of where it should be, and the resource circled in the correct folder) along with a picture of the logo
Any dice if you add
android:scaleType="fitCenter"
android:adjustViewBounds="true"
Edit: also are we sure nothing is overlapping it?
I know that this topic is nothing new, but I really got stuck with this and tried a lot of answers and still I can't make it clear what and where should I write and use.
I have this layout file settings.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
...
<TextView
android:id="#+id/pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/pass_del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="7dp"
android:layout_marginTop="7dp"
android:text="Удалить пароль"
android:textAppearance="?android:attr/textAppearanceMedium" />
...
</LinearLayout>
I have TextView passdel that I want to add programmatically. Its onCreate description is passdel=(TextView) findViewById(R.id.pass_del);
And I have these methods
public void onPasSet() {
pass.setText("Сменить пароль");
((LinearLayout)passdel.getParent()).addView(passdel);
}
public void onPasDel() {
pass.setText("Установить пароль");
((LinearLayout)passdel.getParent()).removeView(passdel);
}
onPasDel is working well.
I guess Java takes current layout. So when I remove View, it's on this layout. And when I try to add this View, Java tries to find this view on current layout, but it's removed, so ..nullpointerexception. How should I write all addView stuff properly? How to point on the needed layout?
Why do you need to remove/add this View? If I understood the goal of this component correctly, the best way will be just to hide/show it:
passdel.setVisibility(View.GONE);
passdel.setVisibility(View.VISIBLE);
Of course, after you've removed passdel from ViewGroup, it has no parents anymore, so you'll get NPE while trying to call onPasSet() after onPasDel()
As you suggested, getParent() won't work intil TextView is not instantiated.
You should get Layout in different way.
You can do it by findViewById(R.id.layout.id).
Example:
In XML:
<LinearLayout
...
android:id="#+id/my_layout">
...
In Activity:
LinearLayout ll = (LinearLayout) findViewById(R.id.my_layout);
ll.addView(myView);