I need to make a Panel on which I'll be able to switch between different custom keyboard views that i have designed.
Something like this
My keypad with navigation panel and custom view of my Numeric keypad
At least two strategies can be applied.
Put your custom KeyboardView inside another ViewGroup, ex.:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
\>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Wazup?!"
/>
<org.dodroid.customime.CustomKeyboardView
android:id="#+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyBackground="#drawable/samplekeybackground"
android:keyPreviewLayout="#layout/preview"
android:popupLayout="#layout/keyboard_popup_keyboard"
/>
</LinearLayout>
Instead of TextView can be your custom panel.
Create one more Row at top with navigation buttons.
Related
I am struggling to find a solution for one of the Android Studio (Kotlin) class problems by Google: how to add another image that scrolls down with the first ScrollView. I created a LinearLayout that has two ScrollViews within it. The first ScrollView has a large amount of text which scrolls down perfectly. However, in the second ScrollView, for the image above the text, it does not scroll down with the text.
Here is a view of the Design element of the activity_main (the green bar below the star is ImageView1 which is in the second ScrollView):
Here is the code for the ScrollViews in my activity_main:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="#+id/bio_scroll2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/button_onoff_indicator_on" />
</ScrollView>
<ScrollView
android:id="#+id/bio_scroll"
android:layout_width="match_parent"
android:layout_height="463dp">
<TextView
android:id="#+id/bio_text"
style="#style/NameStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:text="#string/bio" />
</ScrollView>
</LinearLayout>
Some guidance will be greatly appreciated.
The reason I told you to use only one ScrollView is that you don't need two. You can use any number of views in a Scrollview, just make sure the child of ScrollView is a Layout. You can use any layout and then put whatever you have in that layout. That's how ScrollView is used.
As the official docs of ScrollView state :
Scroll view may have only one direct child placed within it.
To add multiple views within the scroll view, make the direct child
you add a view group, for example LinearLayout, and place additional
views within that LinearLayout.
So, change your code as :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="#+id/bio_scroll2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/button_onoff_indicator_on" />
<TextView
android:id="#+id/bio_text"
style="#style/NameStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:text="#string/bio" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Furthermore, You can remove the root LinearLayout if you don't want to add any other view in it and that will make the ScrollView the root layout.
Also, the height as match_parent doesn't work in ScrollView and it works only as wrap_content or any fix size so if you want to make it take the full height of its parent, you've to use android:fillViewport="true" in ScrollView's tag and height of its parent should be match_parent.
I wanted to create slideshow in my main activity page. After implementing the flipper inside my app, I notice that the FlipperLayout got overlapped with my widget Toolbar. Inside my widget toolbar contains name of the user, where I call the user full name when they are logged into the app.
I'm not quite sure on how to adjust the flipper size to make sure that the slideshow will not overlap with my toolbar. And I want the flipper to be put below the toolbar. Can anyone help me ?
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/frame_layout"
android:layout_above="#id/btm_nav"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/purpleBoo"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark" >
<TextView
android:id="#+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="welcome"
android:layout_gravity="center"
android:textColor="#color/white">
</TextView>
</androidx.appcompat.widget.Toolbar>
<technolifestyle.com.imageslider.FlipperLayout
android:id="#+id/flipper"
android:layout_width="match_parent"
android:layout_height="219dp">
</technolifestyle.com.imageslider.FlipperLayout>
You can edit your FlipperLayout to add android:layout_marginTop="?attr/actionBarSize" attribute
<technolifestyle.com.imageslider.FlipperLayout
android:id="#+id/flipper"
android:layout_width="match_parent"
android:layout_height="219dp"
android:layout_marginTop="?attr/actionBarSize">
OR
You can use a LinearLayout at the root of your layout instead of a FrameLayout, with android:orientation="vertical". This is because the FrameLayout is intended for purposes where child view overlapping is desired.
I am developing custom menu item by calling action layout, but when i am taping that action menu that pressing color is not applying total height giving some top and bottom margin.
Below is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:minWidth="56dp"
android:id="#+id/voicemailNotificationCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:clickable="true"
android:background="#drawable/ab_pressedicon_bgcolor"
android:contentDescription="#string/voicemailnotification"
android:src="#drawable/ab_voicemail">
</ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/vmNotificationTextCounter"
android:text="1"
android:visibility="visible"
android:layout_alignRight="#+id/voicemailNotificationCounter"
android:layout_marginRight="10dp"
android:gravity="center"
android:textColor="#fff"
android:includeFontPadding="false"
android:background="#drawable/notification_alertbg"
android:textSize="12sp"/>
</RelativeLayout>
Part of the problem is that you're not using an ImageButton.
Combining an image with text is possible with an ImageButton. You can even independently adjust the text and the image inside that ImageButton.
Hopefully, an ImageButton will work inside an action menu, I haven't actually tested that part yet.
I need to display a ListView next to a Webview (like the Master/Detail sample), but I need to be able to sort the ListView in a different order (to display some items by category or by name for example), but I did not succeed to make it possible with tabs, dropdown menu or SectionPagerAdapter because the Master/Detail sample uses Fragment, and the TabHost is not a Fragment. I am a bit lost with what I should use.
To make it clear, I want to display it like that :
1
Is there some open source project that use this kind of view, or do your have some advice to perform that ?
You can do it also manually. Just make two list views on top of each other and change their visibilities so only one at a time will be shown.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="64dp"
android:layout_height="match_parent" >
<ListView
android:id="#+id/list_view1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="#+id/list_view2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<WebView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
This is just skeleton of you're UI that you can use.
so im trying to use a relative layout (for basic app tabs at the bottom of the screen) and it is not showing when i place it inside the LinearLayout after 2 other layouts (a LinearLayout and a ScrollView). The ScrollView contains several textViews and scrolls nicely on its own and the linearlayout before it also works nicely, but the relativelayout that i have tried to place at the bottom of the screen does not work.
Here is the general code for what i am trying to do:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#drawable/common_bg"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="50dp">
<TextView android:layout_height="50dp"
android:text="Heading"
android:gravity="center"
android:textSize="17dp"
android:textColor="#color/white"
android:textStyle="bold"
android:layout_width="fill_parent">
</TextView>
</LinearLayout>
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:layout_gravity="top"
android:layout_marginBottom="60dp">
<LinearLayout android:layout_width="fill_parent"
android:orientation="vertical"
android:paddingTop="15dp"
android:layout_weight="1"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content"
android:textColor="#color/white"
android:textSize="18dp"
android:textStyle="bold"
android:text="#string/text"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/bottomMenu"
android:layout_width="wrap_content"
android:layout_height="60dp" />
</LinearLayout>
UPDATE: the Relative layout that im using is custom in a way that i cant actually show the code for it here, but it contains a radio group with several buttons.
UPDATE 2: Ok, so I solved the problem by manipulating the layout_height="wrap_content" on the 3 layouts (the first linear, the one holding the scroller, and the bottom relativelayout) as well as manipulating the layout_wieght of each of them until I was satisfied with the way it looked... it doesnt seem like this is the best possible solution, but it worked so i cant complain too much lol...
The relative layout in itself wont be displayed in an xml graphical layout or when you are running the app, it needs a child element to occupy the parent layout, try putting a text view inside the relative layout, it'll be displayed, position it right below the linear layout having the scroll view, it'll work properly, i just tried it with your code and it works