I am using facebook login. I am trying to change the button, but it dont now work:
I want to make the height 100dp.
Login Page xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF">
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/splash_screen"
android:scaleType="centerCrop"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/label"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textColor="#FFF"/>
<com.gc.materialdesign.views.ButtonFlat
android:id="#+id/bt_skip_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Skip Login"
android:onClick="autoLogin"
android:layout_above="#+id/login_button"
android:layout_centerHorizontal="true"
android:te
xtColor="#FFF"/>
<com.facebook.login.widget.LoginButton
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:id="#+id/login_button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:scaleType="centerInside"
style="#style/FacebookLoginButton"/>
</RelativeLayout>
</RelativeLayout>
Style :
<style name="FacebookLoginButton">
<item name="android:layout_marginTop">10dp</item>
<item name="android:layout_marginBottom">0dp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">90dp</item>
</style>
I want to look like this, but just to fill the width.
I have update my code, Still no change to the login bt
If you want to put custom Facebook button as per your requirement, best option is that you hide the Facebook Login button and Customize the native Android button and put it above the orignal Facebook Login button. Now on click of newly customized button call loginbtn.performClick();. By this way you can change the text of Button also.
Related
So I just went into attributes in android studio to change the color of the button, just like I would the name of the button and other attributes. But now the color seems not to be taking effect when I compile and run on my phone.
I can only see the color change when I change the theme view but, I can not see it when I compile and send to phone.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="#+id/btn_answer2"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_weight="1"
android:background="#FA39D328"
android:backgroundTint="#E10A0A"
android:text="Button" />
This is the only options i have with theme, I can see the the color only on different themes but they do not show up when I run the app. Before changing attributes would change the color
This is the attributes change
Remove android:background="#FA39D328", use only android:backgroundTint="#E10A0A".
<Button
android:id="#+id/btn_answer2"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_weight="1"
android:backgroundTint="#E10A0A"
android:text="Button" />
Use AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/click"
android:background="#FA39D328"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/pay_now"
app:layout_constraintBottom_toBottomOf="parent" />
I can't tell if this is an issue with the material library or from my end.
I'm trying to show two buttons aligned horizontally. However, the first one is showing as it's supposed to show but the other one is not showing as expected.
Here's how the buttons look in Android Studio's layout editor: (expected behavior)
And this is how it shows on a mobile device: (wrong behavior)
My XML is like this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp">
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/view"
android:layout_centerHorizontal="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="7dp"
android:layout_marginBottom="10dp"
android:insetTop="0dp"
android:insetBottom="0dp"
android:text="#string/share_btn_txt"
android:textColor="#FFFFFF"
android:textSize="14sp"
app:backgroundTint="#424242"
app:cornerRadius="#dimen/buttons_corners_radius"
app:elevation="5dp"
app:fontFamily="#font/whitney"
app:icon="#drawable/round_share_white_48dp"
app:iconGravity="textStart"
app:rippleColor="#2D2D2D" />
<View
android:id="#+id/view"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_centerHorizontal="true" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/view"
android:layout_centerHorizontal="true"
android:layout_marginStart="7dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="10dp"
android:insetTop="0dp"
android:insetBottom="0dp"
android:text="#string/download_btn_txt"
android:textColor="#FFFFFF"
android:textSize="14sp"
app:backgroundTint="#color/colorPrimary"
app:cornerRadius="#dimen/buttons_corners_radius"
app:elevation="5dp"
app:fontFamily="#font/whitney"
app:icon="#drawable/round_get_app_white_48dp"
app:iconGravity="textStart"
app:rippleColor="#color/colorPrimaryDark" />
</RelativeLayout>
I'm avoiding using the weight attribute. (tested it as well but still getting the same behavior).
If you guys have any idea how to solve this issue is appreciated.
You can create an xml drawable file for MaterialButton.
btn_drawble.xml =>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#2D2D2D">
<item android:id="#android:id/background">
<shape android:shape="rectangle" >
<corners android:radius="12dp" />
<gradient
android:startColor="#color/color_blue"
android:endColor="#color/color_blue"
android:angle="0"/>
</shape>
</item>
</ripple>
And Set background of button created xml file =>
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/view"
android:layout_centerHorizontal="true"
android:layout_marginStart="7dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="10dp"
android:text="#string/download_btn_txt"
android:textColor="#FFFFFF"
android:textSize="14sp"
app:elevation="5dp"
app:fontFamily="#font/whitney"
android:background="#drawable/btn_drawble"
app:icon="#drawable/round_share_white_48dp"
app:iconGravity="textStart"/>
You'll need to use a material theme.
Set the parent of your app of your AppTheme to a material theme ex: Theme.MaterialComponents.Light.NoActionBar.
Material components require a material theme as parent to work correctly
It seems like it was my fault, I didn't notice that I was changing the button shape dynamically.
Unfortunately, I can't delete this question because Stackoverflow doesn't allow me.
:(
so i'm trying to make an app with buttons, pictures and a tab bar but they don't appear when I drop the button to the virtual phone in android studio.
this is the mainactivity.xml. How can I fix this? This is all description I can give. If you need more, just comment ill try my best to give you more description.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".FullscreenActivity">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<TextView
android:id="#+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true"
android:text="#string/dummy_content"
android:textColor="#33b5e5"
android:textSize="50sp"
android:textStyle="bold" />
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="#+id/fullscreen_content_controls"
style="?metaButtonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button
android:id="#+id/dummy_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/dummy_button" />
</LinearLayout>
</FrameLayout>
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#color/colorAccent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<RadioButton
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<ToggleButton
android:id="#+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton"
android:visibility="visible" />
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextureView
android:id="#+id/textureView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
Try this solutions
Invalidate Cache & Restart
Try Changing theme like AppTheme to Material Light or whatever you want
Clean & Rebuild Project
Done Now you can see the element in Virtual Phone of android studio
Follow below steps:
Go to your res folder and inside res folder.
Go to values.
Go to style.xml
change <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
I am trying to use custom dialogue in one of my android application for edit text. I want show dialogue above the keyboard. I am getting half dialogue hidden below keyboard. I am unable to find solution for it. Let me know if someone expert here can help for solve this puzzle.
My java code for dialogue is like below
final Dialog dialog = new Dialog(NameArt.this,R.style.Theme_Dialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.lyt_dialog_updatename);
//dialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
and XML is like below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edstikertext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_above="#+id/btncancel"
android:hint="Enter text hear" />
<Button
android:id="#+id/btncancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginRight="5dp"
android:layout_alignParentBottom="true"
android:layout_marginEnd="5dp"
android:background="#drawable/boder"
android:layout_marginTop="5dp"
android:text=" Cancel " />
<Button
android:background="#drawable/boder"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/btnok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:text=" OK " />
</RelativeLayout>
and my style is like below
<style name="Theme_Dialog" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
I want dialogue above keyboard, but its getting full height. Thanks
I have just solved it by add this line before show dialogue
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Thanks
See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code?
UPDATE:
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<RelativeLayout android:id="#+id/actionbarRelativeLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#drawable/actionbar_gradient">
<ImageButton android:id="#+id/imageButton" android:layout_width="wrap_content" android:background="#drawable/stocktwits" android:layout_height="wrap_content"></ImageButton>
<TextView android:layout_width="wrap_content" android:id="#+id/charCountTextView" android:text="140" android:layout_alignParentRight="true" android:layout_height="wrap_content" android:textColor="#ffffff" android:textStyle="bold" android:textSize="18sp" android:gravity="center_vertical" android:layout_centerVertical="true"></TextView>
</RelativeLayout>
<EditText android:layout_width="match_parent" android:id="#+id/composeEditText" android:focusable="true" android:hint="Share an idea with the community" android:gravity="left|top" android:layout_height="fill_parent" android:layout_weight="1"></EditText>
<LinearLayout android:layout_width="match_parent" android:id="#+id/border" android:background="#c4c4c4" android:baselineAligned="false" android:layout_height="1dp"></LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:id="#+id/toolbarLinearLayout" android:orientation="horizontal" android:padding="5dip" android:layout_width="fill_parent" android:background="#drawable/gray_toolbar_gradient">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/shortenButton" android:background="#drawable/shortenbutton" android:layout_weight="0"></Button>
<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="#+id/linearLayout1" android:layout_weight="1"></LinearLayout>
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/twitterCheckBox" android:textColor="#000000" android:layout_weight="0" android:background="#drawable/twittergraybutton"></CheckBox>
<Button android:layout_height="wrap_content" android:layout_weight="0" android:id="#+id/sendButton" android:layout_width="wrap_content" android:background="#drawable/sharebutton"></Button>
</LinearLayout>
</LinearLayout>
And here is my Manifest where I specify the softInputMode:
<activity android:name="ShareActivity"
android:theme="#android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustResize">
</activity>
Make sure your soft input mode is set to adjustResize, then place the layout with your toolbar at the bottom of your activity.
Example:
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:id="#+id/my_content"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<!-- Your content here -->
</FrameLayout>
<LinearLayout android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Your toolbar items here -->
</LinearLayout>
</LinearLayout>
This is for people who after setting the adjustResize still did not work, there is an article:
adjustResize does not work in fullscreen
I indeed had this set to fullscreen, when setting my theme back to a nonfullscreen theme the layouts resized just as wanted.
Important addition to the answers above.
When you work with DialogFragment fullscreen is applied implicitly.
That means that you have to:
1) set style in onCreate() of your DialogFragment:
public class YourDialogFragment extends DialogFragment {
...
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Holo_NoActionBar);
}
}
2) if you use your own theme you should handle it like this:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
</style>