Q: SlidingDrawer is Not Scrolling Up - java

My SlidingDrawer is working but not Scrolling Up enough. Handle when come to bottom of the "MENÜYE DÖN" button, stopping! I can't scroll more. I know SlidingDrawer is deprecated but I do not know the alternative.
I can see in Preview, SlidingDrawer's border is narrow.
Here is XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:padding="30dp"
android:textSize="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1. Sözlük hazırlamanın en güç yanı sözcükleri anlam kayganlığından kurtarma, onları belli bir yere oturtmadır. Bu da ancak Samuel Butler’in dediği gibi onların belirsiz yanlarını söz duvarlarıyla kuşatmakla gerçekleşebilir.
Bu cümledeki altı çizili sözle, sözcüklere yönelik olarak ne yapıldığı anlatılmıştır?"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL0">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="A) Tanımsal sınırlar koyulduğu"
android:id="#+id/a" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/LL2"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL1">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="B) Birbirlerinden etkilenişlerinin gösterildiği"
android:id="#+id/b"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL3">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="C) Çağrışımsal değerlerinin belirtildiği"
android:id="#+id/c"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL4">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="D) Zenginleştirme yollarının açıklandığı"
android:id="#+id/d"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL5">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="E) Kullanım sıklığının yansıtıldığı"
android:background="#drawable/flat_button"
android:id="#+id/e"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="20dp">
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="Menüye Dön"
android:background="#bababa"
android:id="#+id/anamenudon"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SlidingDrawer
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:content="#+id/content"
android:handle="#+id/handle"
android:id="#+id/slidingDrawer"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/handle"
android:layout_width="200dp"
android:layout_height="33dp"
android:text="== ÇÖZÜM =="
android:textSize="10dp"/>
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ababab">
<TextView
android:paddingTop="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CEVAP BURADA"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</LinearLayout>

I Found! It works perfectly.
<?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="fill_parent"
>
<ScrollView
android:id="#+id/scrollLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:padding="30dp"
android:textSize="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1. Sözlük hazırlamanın en güç yanı sözcükleri anlam kayganlığından kurtarma, onları belli bir yere oturtmadır. Bu da ancak Samuel Butler’in dediği gibi onların belirsiz yanlarını söz duvarlarıyla kuşatmakla gerçekleşebilir.
Bu cümledeki altı çizili sözle, sözcüklere yönelik olarak ne yapıldığı anlatılmıştır?"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL0">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="A) Tanımsal sınırlar koyulduğu"
android:id="#+id/a" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/LL2"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL1">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="B) Birbirlerinden etkilenişlerinin gösterildiği"
android:id="#+id/b"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL3">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="C) Çağrışımsal değerlerinin belirtildiği"
android:id="#+id/c"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL4">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="D) Zenginleştirme yollarının açıklandığı"
android:id="#+id/d"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL5">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="E) Kullanım sıklığının yansıtıldığı"
android:background="#drawable/flat_button"
android:id="#+id/e"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="20dp">
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="Menüye Dön"
android:background="#bababa"
android:id="#+id/anamenudon"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<SlidingDrawer
android:layout_width="wrap_content"
android:layout_height="250dp"
android:content="#+id/content"
android:handle="#+id/handle"
android:id="#+id/slidingDrawer"
android:layout_gravity="center_horizontal"
android:padding="10dip">
<Button
android:id="#+id/handle"
android:layout_width="200dp"
android:layout_height="33dp"
android:text="== ÇÖZÜM =="
android:textSize="10dp"/>
<LinearLayout
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ababab"
android:gravity="center|top"
android:padding="10dip">
<TextView
android:paddingTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="CEVAP BURADA"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>

Related

Floating Action Button hide and show when scroll in scrollview android?

I have a nestedscrollview with content like some RelativeLayout, CardViews and textviews. I am using a floatingactionbutton library for some reasons, as well. So I can't use any behavior for it. I don't know how I should handle the scrollchangelistener from scrollview to hide and show the fab dynamically like a behavior.
Now, When programs or output cover full page of intent, the fab is totally disappeared. It may be behind the content. I cant access fab. I want the FloatingActionButton over the scrollview. Or show and hide the fab is also need. Please tell how to achieve that concept?
Any suggestions how to hide and show the fab while scrolling?
<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:scrollbars="none"
android:background="#fff"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
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=".programs.PrintANumber">
<android.support.v7.widget.CardView
android:id="#+id/program_title_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/definition_content"
android:layout_centerHorizontal="true"
app:contentPadding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Print a Number"
android:textColor="#color/colorPrimaryDark"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/sourcecode_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/program_title_card"
android:layout_centerHorizontal="true"
app:contentPadding="6dp">
<thereisnospon.codeview.CodeView
android:id="#+id/program"
android:layout_width="match_parent"
android:layout_height="match_parent">
</thereisnospon.codeview.CodeView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/output_title_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/sourcecode_card"
android:layout_centerHorizontal="true"
app:contentPadding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Output"
android:textColor="#color/colorPrimaryDark"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/output_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/output_title_card"
android:layout_centerHorizontal="true"
app:contentPadding="6dp">
<thereisnospon.codeview.CodeView
android:id="#+id/output"
android:layout_width="match_parent"
android:layout_height="match_parent">
</thereisnospon.codeview.CodeView>
</android.support.v7.widget.CardView>
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_singleLine="true"
app:menu_icon="#drawable/fab_add"
fab:menu_backgroundColor="#ccffffff"
app:menu_colorNormal="#color/lightGrey"
android:elevation="2dp">
<com.github.clans.fab.FloatingActionButton
android:id="#+id/id_opt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/opt1"
android:padding="5dp"
fab:fab_size="mini"
fab:fab_label="Option1"
app:rippleColor="#color/colorAccent"
app:fab_colorNormal="#color/colorAccent" />
<com.github.clans.fab.FloatingActionButton
android:id="#+id/id_opt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/opt2"
android:padding="5dp"
fab:fab_size="mini"
fab:fab_label="Option2"
app:rippleColor="#color/colorAccent"
app:fab_colorNormal="#color/colorAccent" />
</com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>
Try like this.
private int oldScrollYPostion = 0; // inside your class
mScrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
#Override
public void onScrollChanged() {
if (mScrollView.getScrollY() > oldScrollYPostion) {
fab.hide();
} else if (mScrollView.getScrollY() < oldScrollYPostion || mScrollView.getScrollY() <= 0) {
fab.show();
}
oldScrollYPostion = mScrollView.getScrollY();
}
});
You are using Floating action inside the scroll view tag. take it out of scroll view.
Use something like this:
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_singleLine="true"
app:menu_icon="#drawable/fab_add"
fab:menu_backgroundColor="#ccffffff"
app:menu_colorNormal="#color/lightGrey"
android:elevation="2dp">
<com.github.clans.fab.FloatingActionButton
android:id="#+id/id_opt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/opt1"
android:padding="5dp"
fab:fab_size="mini"
fab:fab_label="Option1"
app:rippleColor="#color/colorAccent"
app:fab_colorNormal="#color/colorAccent" />
<com.github.clans.fab.FloatingActionButton
android:id="#+id/id_opt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/opt2"
android:padding="5dp"
fab:fab_size="mini"
fab:fab_label="Option2"
app:rippleColor="#color/colorAccent"
app:fab_colorNormal="#color/colorAccent" />
</com.github.clans.fab.FloatingActionMenu>
<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:scrollbars="none"
android:background="#fff"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
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=".programs.PrintANumber">
<android.support.v7.widget.CardView
android:id="#+id/program_title_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/definition_content"
android:layout_centerHorizontal="true"
app:contentPadding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Print a Number"
android:textColor="#color/colorPrimaryDark"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/sourcecode_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/program_title_card"
android:layout_centerHorizontal="true"
app:contentPadding="6dp">
<thereisnospon.codeview.CodeView
android:id="#+id/program"
android:layout_width="match_parent"
android:layout_height="match_parent">
</thereisnospon.codeview.CodeView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/output_title_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/sourcecode_card"
android:layout_centerHorizontal="true"
app:contentPadding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Output"
android:textColor="#color/colorPrimaryDark"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/output_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardElevation="2dp"
android:layout_below="#id/output_title_card"
android:layout_centerHorizontal="true"
app:contentPadding="6dp">
<thereisnospon.codeview.CodeView
android:id="#+id/output"
android:layout_width="match_parent"
android:layout_height="match_parent">
</thereisnospon.codeview.CodeView>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Why the buttons are not shown at the bottom of splitted layout?

Helo,
my code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1.0"
>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:padding="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3sp"
android:background="#color/colorAccent"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
>
<TextView
android:id="#+id/textView32"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/accounts"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10sp"
android:background="#color/colorAccent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_Account_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_description"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold"
/>
</TableRow>
</TableLayout>
<!-- Scrollable Area 1 Begin -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorAccent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<!-- Scrollable Area 1 End -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent"
android:orientation="horizontal">
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto hinzufügen" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center|bottom"
android:paddingBottom="10sp"
android:paddingLeft="20sp"
android:paddingRight="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent2"
android:orientation="vertical"
android:gravity="center|bottom">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="3sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/account_input_output"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_IO_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_date"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Nr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_description"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Ausgabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_ausgabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Eingabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_eingabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent2"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:orientation="horizontal">
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion hinzufügen"
/>
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
My problem is:
The two buttons button6 and button7 below aren't displayed on screen. On android studio they are, but not on my mobile phone.
What am I doing wrong?
This is displayed in android studio gui builder
This is display on android emulator or real device
Hmm... I don't know if it's the best solution.
But I set the bottom padding of the second linear layout to:
20sp + 20 sp + black stripe on the bottom sp + 20 sp
Context context = rootView.getContext();
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
int width = resources.getDimensionPixelSize(resourceId);
LinearLayout l = (LinearLayout)rootView.findViewById(R.id.scrollView2);
float density = context.getResources().getDisplayMetrics().density;
int paddingDp = (int)(20 * density);
l.setPadding(paddingDp, 0, paddingDp, paddingDp + paddingDp + width);

Drawer layout - navigation header is scrolling ANDROID

I've got a problem. There is a a scrollable menu, but the Textview is scrolling too. I don't want to scrolling it.
Here is main XML:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarInner"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:id="#+id/content_frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:layout_below="#+id/toolbar_app_bar_layout">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
<android.support.design.widget.AppBarLayout
android:id="#+id/toolbar_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
app:tabMode="scrollable"
app:paddingStart="16dp"
app:tabPaddingStart="16dp"
app:tabPaddingEnd="16dp"
app:tabMinWidth="96dp"
app:tabGravity="center" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<android.support.design.widget.NavigationView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="#color/md_white_1000"
app:headerLayout="#layout/nav_drawer_header"
app:menu="#menu/menu_drawer"
app:itemTextAppearance="#style/TextAppearance.AppCompat.Menu"
android:clipToPadding="false">
<TextView
android:id="#+id/nav_drawer_wallet_id"
android:layout_width="177dp"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"/>
<TextView
android:id="#+id/nav_drawer_total_credits"
android:layout_width="182dp"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="200dp"
android:layout_marginLeft="16dp" />
<TextView
android:id="#+id/nav_drawer_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:layout_marginTop="150dp"/>
<!--<FrameLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="bottom"-->
<!--android:background="#color/md_white_1000"-->
<!--android:elevation="4dp"-->
<!--android:layout_marginBottom="-96dp">-->
<!--<Button android:id="#+id/navigation_button_footer"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:text=""-->
<!--android:textSize="13sp"-->
<!--android:textColor="#color/md_grey_800"-->
<!--android:lines="3"-->
<!--android:gravity="center"-->
<!--style="#style/Widget.AppCompat.ActionButton"-->
<!--android:paddingTop="20dp"-->
<!--android:paddingLeft="20dp"-->
<!--android:paddingRight="20dp"-->
<!--android:paddingBottom="20dp"/>-->
<!--</FrameLayout>-->
</android.support.design.widget.NavigationView>
<RelativeLayout
android:id="#+id/lay_connection"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/actmain_margintop"
android:background="#3c3c3c"
android:visibility="gone" >
<TextView
android:id="#+id/text_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="#string/error_no_internet"
android:textColor="#color/md_white_1000"
android:textSize="#dimen/twentyfive" />
<RelativeLayout
android:id="#+id/lay_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" >
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/progressBar1"
android:layout_centerHorizontal="true"
android:text="#string/error_no_internet"
android:textColor="#color/md_white_1000"
android:textSize="#dimen/twentyfive" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
I mean about this #+id/nav_drawer_total_credits for example.
EDIT
Here is nav_drawer_header.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/material_color_primary">
<android.support.v7.widget.Toolbar
android:id="#+id/drawer_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:titleTextAppearance="#style/AppTheme.Widget.Toolbar.Title"
android:theme="#style/AppTheme.Widget.Toolbar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:paddingBottom="0dp"
android:layout_margin="0dp"/>
<ImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher"/>
<TextView android:id="#+id/nav_drawer_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:layout_marginTop="0dp"/>
<TextView android:id="#+id/nav_drawer_total_credits"
android:layout_width="182dp"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:text="Credits:"/>
<TextView android:id="#+id/nav_drawer_wallet_id"
android:layout_width="177dp"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:text="Wallet ID:"/>
</LinearLayout>
And the JAVA code:
mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.END);
mDrawerLay = (NavigationView)findViewById(R.id.navigation_view);
mDrawerLay.setNavigationItemSelectedListener(this);
navigationTotalCreditTextView = (TextView)findViewById(R.id.nav_drawer_total_credits);
navigationTotalCreditTextView.setText("Total Credits: " + PreferenceConnector.readInteger(aiContext,
PreferenceConnector.WALLETPOINTS, 0));
navigationWalletIDText = (TextView)findViewById(R.id.nav_drawer_wallet_id);
navigationWalletIDText.setText("Wallet ID: " + PreferenceConnector.readString(aiContext,
PreferenceConnector.WALLETID, ""));
navigationUsernameText = (TextView)findViewById(R.id.nav_drawer_username);
navigationUsernameText.setText(PreferenceConnector.readString(aiContext,
PreferenceConnector.USERNAME, ""));
Here is how it should be and how it is when no scrolling menu
Here is how it looks like after scrolling down

how to display all items in the listview

I'm trying to include a ListView on a screen that already exists in my app.
My problem is that the ListView is displaying only the first item. I wish it were
displayed all the list.
Here is the my screen's xml:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/radialback"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:orientation="vertical"
android:shrinkColumns="*">
<TableLayout
android:id="#id/tabela_cuerpo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow
android:id="#id/tableRow0"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_cabecalho"
android:gravity="center_horizontal"
android:text="Corrida Recebida"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
</TableRow>
<TableRow
android:id="#id/tableRow1"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Cliente: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPassageiro"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow2"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Distância: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtDescricao"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow3"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Endereço:"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtEndereco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow4"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Valor: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtValor"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="R$ 0,00"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow5"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Telefone: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPtoReferencia"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:autoLink="phone"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
</TableLayout>
<ListView
android:id="#+id/pedidos_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<Button
android:id="#id/btnAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_green"
android:text="Aceitar"/>
<Button
android:id="#id/btnVerMapa"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Mapa"/>
<Button
android:id="#id/btnVerOrigemWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Origem"/>
<Button
android:id="#id/btnVerDestinoWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Destino"/>
<Button
android:id="#id/btnInformarTmpEstimado"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Tempo Estimado"/>
<Button
android:id="#id/btnClienteBordo"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Produto Já Recolhido"/>
<Button
android:id="#id/btnInformarValor"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Informar Valor"/>
<Button
android:id="#id/btnRejeitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Rejeitar"/>
<Button
android:id="#id/btnCancelarAposAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Cancelar Corrida"
android:visibility="invisible"/>
<Button
android:id="#id/btnFinalizar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Finalizar Corrida"
android:visibility="invisible"/>
</LinearLayout>
</ScrollView>
The screen is getting as follows:
http://anstaxi.com.br/android-screen-current-wrong.png
I need all the items are displayed.
The code snippet is:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_corrida_multiponto);
String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview_pedidos, mobileArray);
ListView listView = (ListView) findViewById(R.id.pedidos_list);
listView.setAdapter(adapter);
}
-
You problem is using a listview inside a scrollview. Listview cant streatch itself inside the scrollview.
And after solving this issue. You will have problem with th scrolling (which one to scroll?)
But this link solves your problem:
Android list view inside a scroll view

How to animate changing the alpha of a FrameLayout's foreground drawable?

I am trying to find a way to animate changing the alpha of a FrameLayout's foreground drawable, but i cant seem to find a way of doing it.
If someone could point me in the right direction as to how i should go about this i would be hugely grateful.
The relevant code is below:
XML layout file:
<com.bacon.corey.audiotimeshift.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="0dp"
sothree:shadowHeight="10dp"
sothree:paralaxOffset="100dp"
sothree:fadeColor="#android:color/transparent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:id="#+id/recordingListMainLayout"
android:foreground="#drawable/dim_shadow_shape_dark"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainLayoutContainer"/>
<!--
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:padding="0dp"
android:layout_margin="0dp"
/>
-->
</LinearLayout>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionsMenu
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:gravity="right"
app:fab_addButtonColorNormal="#color/holo_red_light"
app:fab_addButtonColorPressed="#color/c16"
app:fab_addButtonPlusIconColor="#color/white"
app:fab_expandDirection="up"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c15"
app:fab_colorPressed="#color/c15"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c8"
app:fab_colorPressed="#color/c8"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a1"
app:fab_colorPressed="#color/a1"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a2"
app:fab_colorPressed="#color/a2"
app:fab_size="mini"
/>
</LinearLayout> </com.bacon.corey.audiotimeshift.FloatingActionsMenu>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:textSize="16sp"
android:id="#+id/slideUpPanel"
>
</FrameLayout>
</com.bacon.corey.audiotimeshift.SlidingUpPanelLayout>
And the java code that i use to change the alpha of the foreground:
fabMain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
boolean expanded = fabMenu.toggle();
mainActivity.getDimShadowDrop().setForeground(getResources().getDrawable(R.drawable.dim_shadow_shape_light));
mainActivity.getDimShadowDrop().getForeground().setAlpha(180);
if (expanded){
((MainActivity)getActivity()).replaceFragment(new RecordFragment(), R.id.slideUpPanel, false);
slidingUpPanelLayout.expandPanel();
defaultColor = getResources().getColor(R.color.recordDefaultColor);
}
}
});
Instead of the typical way you do it with an Animation which is from 0 to 1 you use 0 to 255. Something like this will pulse the Foreground of a CardView.
public static void pulseForeground(CardView view, long duration) {
ObjectAnimator animator = ObjectAnimator.ofInt(view.getForeground(), "alpha", 0, 255);
animator.setDuration(duration);
animator.setStartDelay(20);
animator.setRepeatMode(Animation.REVERSE);
animator.setRepeatCount(Animation.INFINITE);
animator.start();
}

Categories

Resources