Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After updating the library from April to today's version, button suddenly not displayed correctly #70

Closed
kamilwlf opened this issue Dec 2, 2014 · 7 comments
Labels

Comments

@kamilwlf
Copy link

kamilwlf commented Dec 2, 2014

right image gone, format changed(now center work)
all

@jamie-beardedhen
Copy link
Contributor

Can you please post a code snippet that can be used to reproduce this behaviour?

@kamilwlf
Copy link
Author

kamilwlf commented Dec 2, 2014

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
      android:clipToPadding="false"
        android:fitsSystemWindows="true"
    xmlns:card="http://schemas.android.com/apk/res-auto"
        android:paddingTop="5dp">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@color/my_third" >

<include layout="@layout/fragment_button" />

 </LinearLayout>
</ScrollView>

fragment_button:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/widget191"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <com.beardedhen.androidbootstrap.BootstrapButton            
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/xxx"
            bootstrapbutton:bb_icon_left="fa-check-square-o"
            bootstrapbutton:bb_icon_right="fa-hand-o-right"
            bootstrapbutton:bb_roundedCorners="true"
            bootstrapbutton:bb_type="primary"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"/>

        <com.beardedhen.androidbootstrap.BootstrapButton
            android:id="@+id/about"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/about"
            bootstrapbutton:bb_icon_left="fa-info-circle"
            bootstrapbutton:bb_icon_right="fa-hand-o-right"
            bootstrapbutton:bb_roundedCorners="true"
            bootstrapbutton:bb_type="primary"
            android:paddingBottom="5dp"
            />
...

@jamie-beardedhen
Copy link
Contributor

This bug occurs when a BootstrapButton has a layout_width of match parent or uses weighting. The middle label occludes the right icon - setting its width to wrap_content breaks the text alignment code.

This may require a bit of time to fix as it looks like the layout will need to be switched to a RelativeLayout, and the label padding/text alignment code will also need changing.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:duplicateParentState="true"
    android:orientation="horizontal"
    android:paddingBottom="10dp"
    android:paddingTop="10dp">

    <TextView
        android:id="@+id/lblLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:paddingLeft="15dp"
        android:visibility="gone" />

    <TextView
        android:id="@+id/lblMiddle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:visibility="gone" />

    <TextView
        android:id="@+id/lblRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:paddingRight="15dp"
        android:visibility="gone" />

</LinearLayout>

@fmakdemir
Copy link

Hello,
If it is not something urgent in 2 weeks I will be free and as I said before I was thinking of making rotating button icons. In order to make them I already enhanced the padding/margin calculations. So my local probably will solve this issue as well. Or if someone is working on it I can wait.

@jamie-beardedhen
Copy link
Contributor

I haven't looked into this yet, but it's possible I might get a chance over the next few weeks. If I do start work on it I'll leave a comment in here, as there's no point duplicating effort. Rotating icons would also be very welcome.

@ian2009
Copy link

ian2009 commented Jan 22, 2015

  • I also ran into this issue in my Nexus 4 (OS Android 5.0).
  • After struggling a day of modifying and testing, following changes for the lblMiddle in the button Layout fixed my problem, hope it will be helpful:
    android:layout_width="0dp"
    android:layout_weight="1"
  • The whole layout of the button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:duplicateParentState="true"
    android:orientation="horizontal"
    android:paddingBottom="10dp"
    android:paddingTop="10dp">

    <TextView
        android:id="@+id/lblLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:paddingLeft="15dp"
        android:visibility="gone" />

    <TextView
        android:id="@+id/lblMiddle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:visibility="gone" 
        android:layout_weight="1"
    />

    <TextView
        android:id="@+id/lblRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:paddingRight="15dp"
        android:visibility="gone" />

</LinearLayout>

ian2009 added a commit to ian2009/Android-Bootstrap that referenced this issue Jan 22, 2015
…version, button suddenly not displayed correctly
@jamie-beardedhen
Copy link
Contributor

@ian2009 thanks for your fix, I'll try and test it out at some point over the next few days. Would you mind creating a PR?

jamie-beardedhen added a commit that referenced this issue Jan 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants