Facebook LikeView change button size - java

I am using a LikeView in my android application and want to change the button size. Changing the view's size using layout parameters or the width/height at addView() does not help.
I'm using libGDX and have never worked with XML + libGDX, so a way to do it with code only would be nice!
Does anyone know how to do this? Currently I use the following code to create my LikeView:
likeButton = new LikeView(application);
likeButton.setLikeViewStyle(LikeView.Style.BUTTON);
likeButton.setX(x);
likeButton.setY(y);
likeButton.setObjectId(LIKE_URL);
likeButton.setVisibility(View.GONE);
application.layout.addView(likeButton,width,height);
likeButton.invalidate();
application.layout is a RelativeLayout

Try to create your LikeView from XML (or inflate this layout at runtime):
<com.facebook.widget.LikeView
android:id="#+id/button_like"
android:layout_height="31dp"
android:layout_width="wrap_content" />

I finally fixed it using setScale on the view. It's not the most elegant solution, but it does the job.
likeButton.setScaleX(1.8f);
likeButton.setScaleY(1.8f);

Related

Java: How to add a png image to the middle of a sentence

It should look like this:
I'm specifically using android studio. I currently have a textview and my text in the strings.xml file, but I understand there are other ways of doing the code. I have several paragraphs to write, so I figured this would be the best place to insert the text. I will need to include an image, a button, and links straight into the sentences I'm writing. (Any advice for each of those would be helpful) But, my first issue is that I don't know how to add the image into the middle of the sentence. All relevant posts are incomplete or outdated.
I would suggest if you wish to display large amount of text then use something like WebView with some html template engine.
To achieve this you need to use setCompoundDrawablesWithIntrinsicBounds() method of TextView. Heopfully this will help you.
Or you can use **SpannableStringBuilder ** for this to get. I hope this will help you.
UPDATED: Here sample is available. I am attaching link as well. It will help you in your implementation
https://stackoverflow.com/questions/15352496/how-to-add-image-in-a-textview-text
I have implemented this type of code in my app but I was used dependency which I describe here...
Implement this dependency in your build.gradle file
implementation 'org.sufficientlysecure:html-textview:4.0'
and then write this line in your build.gradle(Root level) or on the settings.gradle file
repositories {
jcenter()
}
Layout.xml
<org.sufficientlysecure.htmltextview.HtmlTextView
android:id="#+id/textView"
android:textAppearance="#android:style/TextAppearance.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="13dp" />
In your Activity.java file in OnCreate Method
TextView textView;
textView = (TextView) itemView.findViewById(R.id.textView);
textView.setHtml("<b>Hello</b> this is my Text <span/> <img src="yourimage.jpg"> <span/> Another Text, new HtmlHttpImageGetter(myHolder.question));

How to change background of the app?

Is there a way to change background directly in the app? (!not homescreen wallpaper)
You need to specify the layout that its background will be changed. I guess you have a LinearLayout, so add an id to the layout (if it is not exist):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id=#+id/parentLayout>
Then you can change the background in Java with:
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.parentLayout);
linearLayout.setBackgroundResource(R.drawable.new_background);
Hope it helps you!
i have a link for you is easy to change background app.
Try something like that https://www.youtube.com/watch?v=mDKuWIlSNJE

Zoom ImageView in android like Instagram

How can I zoom ImageView like Instagram. I mean changing the size of imageview, not zooming the image inside the Imageview.
For zooming the image inside the Imageview, there are a lot of samples but I want something like Instagram image zooming
Any code or hint? Thanks.
I recommend Zoomy, very simple and functional.
Just add the following to your current ImageView:
Zoomy.Builder builder = new Zoomy.Builder(this).target(mZoomableView);
builder.register();
I would recommend these two libraries:
PhotoView
ImageViewZoom
For PhotoView, you just have to create an attacher and "attach" it to your ImageView.
Some code
// After getting your imageImage view, attach it like the following
PhotoViewAttacher yourAttacher = new PhotoViewAttacher(yourImageView);
With just this code, you'll be able to zoom in/out/whatever on yourImageView. Check the links above for more details.
EDIT
Instagram has changed a lot since this answer was posted, and the libraries I recommended above might not provide the experience you are looking for.
thanks
I have added this to my gradle.build
compile 'it.sephiroth.android.library.imagezoom:imagezoom:2.2.5'
and then using this view
<it.sephiroth.android.library.imagezoom.ImageViewTouch
android:id="#+id/mp3Image"
android:adjustViewBounds="true"
android:layout_width="346dp"
android:layout_height="356dp"
android:scaleType="fitCenter" />
and the below code, the zoom came to my app
myImage = (ImageViewTouch) findViewById(R.id.mp3Image);
myImage.setDisplayType(ImageViewTouchBase.DisplayType.FIT_IF_BIGGER);

Create simple text popup for textview

I'm new to android and started to learn java, i found an app called learn java and i notice the popup appear when i tap a text view,here is a screen shot
is there a simple way to do this in android studio like textview.showpoponupclick("text") or i have to invent it,i saw some tutorials to make .XML and a lot of coding, but i only want to show some text similar to the edittext.setError(); . and sorry for my English.
Do refer some external libraries like this.
As sample use its layout XML like here provided
<com.nhaarman.supertooltips.ToolTipRelativeLayout
android:id="#+id/activity_main_tooltipRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
And create a tooltip view from java code
ToolTipRelativeLayout toolTipRelativeLayout = (ToolTipRelativeLayout) findViewById(R.id.activity_main_tooltipRelativeLayout);
ToolTip toolTip = new ToolTip()
.withText("A view")
.withColor(Color.RED)
.withShadow()
.withAnimationType(ToolTip.ANIMATIONTYPE_FROMTOP);
myToolTipView = toolTipRelativeLayout.showToolTipForView(toolTip, findViewById(R.id.activity_main_redtv));
myToolTipView.setOnToolTipViewClickedListener(MainActivity.this);

Android TextView Wrap

Here is my problem. How to make text don't wrap?
I already tried to make text smaller. Didn't work. Tried to do singleline="true". Here is what he do(2 screen shot 6-7 textview)
1 Screenshot) Here is I made it in the Eclipse
2 Screenshot) Here is how it showen in the emulator
Try setting android:ellipsize to none for each TextView. For more details see documentation on this attribute.
From xml:
<TextView ... android:ellipsize="none" />
From code:
TextView textView = new TextView(context);
...
textView.setEllipsize(null);
try giving android:maxLines=1... singleLine property should also work...

Categories

Resources