Android LoginButton Facebook no action size height

I have use button facebook, but when set size height, it is no success. Can you help me. It my code :

<com.facebook.login.widget.LoginButton android:id="@+id/btn_login_facebook" android:layout_width="match_parent" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_marginBottom="10dp" android:layout_marginTop="20sp"/>

-------------Problems Reply------------

You can setPadding for your facebook Like box.

FacebookLikeBox.class

package com.example.facebook;

import com.example.facebook.FacebookLinkStatProcessor.Result;
import com.example.fblike.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;

public class FacebookLikeBox extends Button {
private static final String LOG_TAG = FacebookLikeBox.class.getSimpleName();
private static final Looper BACKGROUND;

static {
HandlerThread thread = new HandlerThread(FacebookLikeBox.class.getSimpleName(), Process.THREAD_PRIORITY_LOWEST);
thread.start();
BACKGROUND = thread.getLooper();
}

private Handler mHandler;
private FacebookLinkStatProcessor mProcessor;
private String mUrl;
private boolean mAttachedToWindow;

private CalloutPath mPath;
private ShapeDrawable mFill;
private ShapeDrawable mStroke;
private float mCornerRadius;
private int mCalloutMarker;

public void setProcessor(FacebookLinkStatProcessor processor) {
mProcessor = processor;
}

public void setPageUrl(String url) {
String old = mUrl;
mUrl = url;

if (old == null && url != null || old != null && !old.equals(url)) {
onUrlChanged(old, url);
}
}

@SuppressLint("NewApi")
@Override
public boolean isAttachedToWindow() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return mAttachedToWindow;
} else {
return super.isAttachedToWindow();
}
}

public FacebookLikeBox(Context context) {
super(context);
init(null);
}

public FacebookLikeBox(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}

public FacebookLikeBox(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}

private void init(AttributeSet attrs) {
mProcessor = new FacebookLinkStatProcessor();

mHandler = new Handler(BACKGROUND, new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
processUrl((String) msg.obj);
return true;
}
});

if (attrs == null) {
return;
}

Context c = getContext();
if (c == null) {
return;
}

TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.FacebookLikeBox);
if (a == null) {
return;
}

Resources r = getResources();
if (r == null) {
return;
}

try {
mPath = new CalloutPath();
mFill = new ShapeDrawable();
mFill.getPaint().setStyle(Paint.Style.FILL);
mFill.getPaint().setColor(a.getColor(R.styleable.FacebookLikeBox_boxFillColor, r.getColor(R.color.com_shamanland_facebook_like_box_background_color)));
mStroke = new ShapeDrawable();
mStroke.getPaint().setStyle(Paint.Style.STROKE);
mStroke.getPaint().setColor(a.getColor(R.styleable.FacebookLikeBox_boxStrokeColor, r.getColor(R.color.com_shamanland_facebook_like_box_text_color)));
mStroke.getPaint().setAntiAlias(true);
mStroke.getPaint().setStrokeWidth(a.getDimension(R.styleable.FacebookLikeBox_boxStrokeWidth, r.getDimension(R.dimen.com_shamanland_facebook_like_box_stroke_width)));
mCornerRadius = a.getDimension(R.styleable.FacebookLikeBox_boxCornersRadius, r.getDimension(R.dimen.com_shamanland_facebook_like_corners_radius));
mCalloutMarker = a.getInt(R.styleable.FacebookLikeBox_calloutMarker, 0);

initBackground();
} finally {
a.recycle();
}
}

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void initBackground() {

Drawable drawable = new LayerDrawable(new Drawable[]{mFill, mStroke});
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
setBackgroundDrawable(drawable);
} else {
setBackground(drawable);
}

setPadding(5, 5, 5, 5); // you can do your padding.
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mAttachedToWindow = true;
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mAttachedToWindow = false;
}

@Override
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
mPath.build(mCalloutMarker, w, h, mStroke.getPaint().getStrokeWidth(), mCornerRadius);
PathShape shape = new PathShape(mPath, w, h);
mFill.setShape(shape);
mStroke.setShape(shape);
}

protected void onUrlChanged(String oldValue, String newValue) {
setText(R.string.com_shamanland_facebook_like_box_text_default);

if (oldValue != null) {
mHandler.removeMessages(0, oldValue);
}

if (newValue != null) {
Message msg = Message.obtain();
if (msg != null) {
msg.obj = newValue;
mHandler.sendMessage(msg);
}
}
}

/**
* Background thread
*/
protected void processUrl(final String url) {
try {
final Result result = mProcessor.processUrl(url);
post(new Runnable() {
@SuppressLint("NewApi")
@Override
public void run() {
if (isAttachedToWindow()) {
postProcessUrl(url, result);
}
}
});
} catch (Throwable ex) {
ex.printStackTrace();
/*if (LOGGING) {
Log.wtf(LOG_TAG, ex);
}*/
}
}

protected void postProcessUrl(String url, Result result) {
if (url.equals(mUrl)) {
onUrlProcessed(result);
}
}

protected void onUrlProcessed(Result result) {
setText(prettyNumber(result.shares));
}

protected String prettyNumber(long number) {
if (number > 1000000000L) {
return number / 1000000000L + "." + (number % 1000000000L) / 100000000L + "b";
} else if (number > 1000000L) {
return number / 1000000L + "." + (number % 1000000L) / 100000L + "m";
} else if (number > 1000L) {
return number / 1000L + "." + (number % 1000L) / 100L + "k";
} else {
return String.valueOf(number);
}
}
}

Category:android Views:59 Time:2018-12-19

Related post

  • How to make android EditText smaller than default in height? 2009-09-01

    How to make android EditText smaller than default in height? If I change the height, I can't see my text, but it has extra blank on bottom. --------------Solutions------------- EditText has a default padding set. Try this, <EditText android:text="

  • Android: Changing the camera preview size on screen 2011-08-10

    Currently, the Camera Preview is stretched to fit the entire screen (854x480). I'd like it to display (427x240) instead. Here is the relevant code for the camera implementation: Camera.Parameters params = camera.getParameters(); params.setPreviewSize

  • Android gridview adjusting to screen size 2012-01-02

    The grid view of my application has 3 rows and 3 columns. I want this to fill the screen ,irrespective of the screen size of the device. I tried getting window size and setting the layoutparams accordingly. But this is not giving a perfect alignment

  • Get back original size (height, width) from UIImage load with imageWithData 2010-04-25

    I just cant find useful information from web. I have an UIImage which loaded from sqlLite with method imageWithData(NSData*), I just find the height and width of the size both be zero. I wanna get back the original height and width of the image, is i

  • Set UIView.frame.size.height to zero to hide content? 2010-07-20

    UIView *stateView = [getSomeUIView thisOne]; CGRect currentFrame = stateView.frame; if(currentFrame.size.height == 0.0) { currentFrame.size = CGSizeMake(260, 60); } else { currentFrame.size = CGSizeMake(260, 0); } stateView.frame = currentFrame; I wo

  • View Frame Size Height = 0 2010-09-10

    I`m getting 0 when I return this from my ViewController : NSLog(@"%i",self.view.frame.size.height); In Interface builder, the View it's managing is occupying the entire screen . Help ? --------------Solutions------------- Height is a float. Use %f to

  • view.frame.size.height changing in UIViewController 2010-09-20

    Inside my view, I have a table and an ad banner, all of which are created through Interface Builder. But I noticed that my view.frame.size.height seems to change through the course of execution of my app even though I haven't changed the size. Can so

  • Android - Native Facebook app causing invalid_key error? 2011-04-30

    I'm working on implanting Facebook in my app. Now I didn't put the Hash Key because I don't want the Single Sign On feature. I managed to get it it work, but if I have the native Facebook app on my device I get an 'invalid_key error'. If I uninstall

  • Detect div size (height) while filling content (from database) 2011-06-03

    I want to detect the div size height while filling content (from database). If the div height exeed 800px, then draw new div as new content wrapper and fill the remain content inside. The illustration is like the following : Single content wrapper pr

  • Getting size, height and width of an image? 2011-07-23

    How can I get the size, height and width of an image in when upload it with jQuery? --------------Solutions------------- if you use jquery uploadify plugin then you can find the file size by any one of these following method 'onSelect': function(even

  • Why is self.bounds.size.height not taking into account the UINavigationView nav bar in this code? 2011-08-03

    I have a configuration UITableView that can launch a colour picker via a UINavigationController approach: [self.navigationController pushViewController:colorPickerViewController animated:YES]; [colorPickerViewController release]; The effect of this m

  • CoreText flip coordinates self.bounds.size.height error bounds 2011-08-28

    I am drawing text in the view with CoreText. To learn this I used a tutorial, but suddenly it uses self.bounds.size.height, in a part where it flips the coordinate system. When I was duplicating the code in Xcode it gave an error because 'bounds' was

  • Is there a way to declare background-size-height? 2011-12-11

    Is there a way to declare background-size-height, or something close to that? I want the background image to fit 100% height but keep it's proportions, aka width still dynamic. Thanks for any pointers. --------------Solutions------------- See this ar

  • the frame.origin.y change on when I change UIVIew's bounds.size.height 2011-12-23

    (my english is not very well LOL) i defined a UIView object as a subview, when i change the subview.bounds.size.height, the subview.frame.origin.y changed, is there something wrong in my code? here is my code: - (IBAction)touch { static int i = 1; NS

  • The container 'Android Dependencies' references non existing library 'facebook-android-sdk\facebook\bin\com_facebook_android.jar' 2012-04-20

    I am trying to use the facebook sdk within my project, however keep receiving the following error: The container 'Android Dependencies' references non existing library 'facebook-android-sdk\facebook\bin\com_facebook_android.jar' Has anyone experience

  • android: how to change Text size, color of Options Menu Items and options menu height and width 2011-02-22

    I have used the following code to customize the background of options menu successfully. getLayoutInflater().setFactory(new Factory() { @Override public View onCreateView(String name, Context context, AttributeSet attrs) { if (name.equalsIgnoreCase("

  • Android contextmenu item size / height, how to change? 2011-06-25

    How can i change the contextmenu item's size? height? Thanks, Leslie --------------Solutions------------- It's not really intended to be modified - it's there to handle menu in standard way. There are some ways to modify the menu and its items (for e

  • Android: How to change CheckBox size? 2010-01-27

    I would like to make CheckBox a bit smaller/bigger, how can I do this? --------------Solutions------------- You just need to set the related drawables and set them in the checkbox: <CheckBox android:layout_width="wrap_content" android:layout_heigh

  • Android: How to change the Size of the RadioButton 2010-06-10

    I have many RadioButtons in mein App. The RadioButtons are too big for me. Is there any way to make it smaller? --------------Solutions------------- Can't be done, the radio button is a built-in control component and as such its size is fixed. It can

  • Android how to sniff screen size from webkit browser? 2010-11-08

    The webserver wants to get info like screen size from each mobile handset that browses a webpage. The Javascript functions screen.width and screen.height return wildly inaccurate values. Is there a way for the webserver to detect the screen size of t

  • How do you begin developing an Android app for multiple devices sizes/densities? 2010-12-09

    I've asked a question similar to this but thought I would ask a more general question to get a wider range of input. I ask this question because the last two apps I've developed, I threw all image resources in the drawable-hdpi folder, didn't deal wi

  • Android: Multiple Image Density support - scale height width and dpi? 2011-01-28

    I have an android app that I'm trying to add support for different densities, screen sizes, etc. I've developed the app on the simulator with the HVGA support and used all icons from our iphone app which turns out nice since the resolution was at 320

  • Android ListView not taking up its height 2011-06-09

    I have a very strange problem here. In the following xml section I'm trying to use include: <!-- CONTENT --> <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:fadingEdge="none"> <LinearLayout an

  • Android | How do I define the height and width of a 9-Patch PNG so it won't get pixelized 2011-07-26

    I have discovered the main idea of how to deal with regular PNG for Android. Let's say I have created in my computer an icon the size of 60*120px. I know that for hdpi (800*480px) I need to divide it by 1.5 in order to get the right dp - so it will b

  • Android: Layout breaks when Text Size changed 2011-08-02

    following is my android layout for 3 buttons. Its looks nice and good. But when I change the button's Text size of a single button to some other value it breaks the layout (font size and gravity changed but). before <LinearLayout android:weightSum

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.208 (s). 11 q(s)