I am trying to achieve a similar look like the Google Play Store App
For now I got this
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="200dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="200dp" />
</FrameLayout>
Looks great but since the Recyclerview is overlapping the ImageView, it's not clickable anymore. I am looking for a solution.
You can make use of scrolling activity template in the android studio it has similar behaviour to what you want to do.
and put ImageView in AppBarLayout
and handle the click events like any other view.
this won't give you the exact behaviour of google play app but if it's the eases way to do it.
if you want the exact behaviour I know an open source library that do that let me know if you want it and I will search for it.
Related
i want fill CardView with custom text and image such as listview, but i dont know :( Please see the sample picture to better understand what I mean
Simple Picture : simple picture link.
i use this link for CardView : CardView Link
I am an amateur, please give me the source code
You have pretty much all you need from the Android documentation. Just gonna give you a couple things that might not be obvious.
CardViewis a child of FrameLayout so you basically want to build a Frame Layout with text and and image. If you are not familiar with FrameLayout what you need to do is put a LinearLayout (or any other that you find appropriate) inside the FrameLayout (or the CardView for this case) and add your other widgets inside.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
... >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<--This is where you add the text and image-->
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Try that and if you get stuck we can always help, but don't let the fact that you are new to Android stop you from doing things yourself, don't just ask for the code without trying first or you will always be an amateur
I want to create news like activity that has title and date and some share and favorite buttons in the beginning at the top, the article text (and maybe some images and headers titles) is in html that I get from server, and at the end a list of related news!
I have to use WebView for the article html, but since I need the header and the main webview to scroll together, I may have to use them in the in wraping ScrollView, which, apparently is not the best option!
I have red these:
webview in scrollview and
Disable scrolling in webview
but I want to know what is the best way to implement this as of 2015! that can work with android 4.01+
Well, as it turns out, best way to do yet is to just put them in a scrollView !
It worked on my Samsung android 4.4, but I don't know about the rest !
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/news_activity_title_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//Some Widgets Here for header
</RelativeLayout>
<WebView
android:layout_below="#+id/news_activity_title_lay"
android:id="#+id/news_activity_web_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
</WebView>
<LinearLayout
android:id="#+id/news_activity_related_base_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/news_activity_web_view">
//Some Widgets Here foe footer
</LinearLayout>
</RelativeLayout>
funny thing, though is Android Studio is saying I should not do this ! :/
I want to show and hide the action bar /toolbar as the Google Play store app. I am using sliding tabs on top and view pager to show the content of each tab. Here is the screenshot of Google play store app for the reference:
My layout XML :
<?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">
<LinearLayout style="#style/HeaderBar"
android:id="#+id/headerbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/toolbar_no_bg"
android:id="#+id/toolbar_actionbar"/>
<com.fauzie.sample.tabsspinner.widget.SlidingTabLayout
android:background="#color/tab_background"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/headerbar">
</android.support.v4.view.ViewPager>
</RelativeLayout>
Thanks in advance.
Have a look at this:
https://github.com/flavienlaurent/NotBoringActionBar
There's a trick involved here. You'll need to:
Wrap your layout in a list view
Add a fake header with the same height as your action bar large header
set your action bar overlay to true
Translate the real header when the list moves (i.e. when the fake header is scrolled).
It's a little bit complicated at first but once you understand it, you see how smart and obvious it all is. The link will give you all you need I hope.
I myself used that link to implement it in my own app and it works great.
Checkout this library: https://github.com/ksoichiro/Android-ObservableScrollView
this will definitely help you
Check this example to implement this with the new official Android Design Support Library:
https://github.com/chrisbanes/cheesesquare
I want to display two different activities in a single screen how can i do that in android?Please if anybody has idea share it.And I don't wanna use fragments.
I want to display a screen which contains some fields and below(at the bottom of the screen) I want another screen with some buttons.
Is this possible in android?
If so, How can i do this ?
You can't have two activities in one screen. You can have only one. So, ultimate solution is Fragments.
An activity is not directly a visual component, so I'm thinking that what you're really asking is how to have a single activity display different views.
There's nothing that says you can't rerun setContentView() with a different layout/view ID. But there's another non-fragments way of doing what your probably want.
You can define more than one full-size (match_parent) view in a layout. What you want to do is set the visibility for one of them to "visible" with android:visibility="visible" and all the others to "gone" with android:visibility="gone".
Then when you want to switch the displayed view, you'll run setVisibility(View.GONE) on the outgoing view and setVisibility(View.VISIBLE) on the incoming. It's important to use GONE and not INVISIBLE or the layouts won't render correctly.
Sample layout file:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
<SurfaceView
android:id="#+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<WebView
android:id="#+id/web"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
Sample Code to switch view:
video.setVisibility(View.VISIBLE);
img.setVisibility(View.GONE);
web.setVisibility(View.GONE);
That said, you probably want to learn how to use fragments since you can handle switching the view along with other state in a single unit of work (a transaction). But the above approach above does work for simple view changes.
I am about finishing my first android app, and i have some questions to which i could not find an answer.
I would like to use a horizontal scroller in which to display several pictures. For that i need two things:
Paging enabled, so that the user can see the pictures one by one in the scroller.
Some kind of indicator to show me the index of the picture currently displayed.
If i manage to do the paging, i could probably display a text like 1/4 (2/4 and so on) if i had 4 pictures, but it is not very nice. I would like to have something more like the iPhone has with the gray/white dots. Is there anything like that, or would i have to implement it by adding content at runtime? (adding imageviews according to the number of the pictures and then changing images for them as the user scrolls to show progress)
Thank you.
Because I was already using ViewPager for the swiping UI, I used the excellent ViewPagerIndicator. It took about 5 minutes to integrate.
<?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="#000000">
<include android:id="#+id/titlebar_include" layout="#layout/titlebar"/>
<include layout="#layout/menu"/>
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:id="#+id/product_viewpager"
android:layout_height="0dp"
android:layout_weight="1"
/>
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
I found the answer i was looking for: i used the Gallery widget and for the indicator dots i used ImageViews and wrote a couple of lines of code to update the selected image dot.
Here is the solution you can try: PageViews and PageIndicator by GreenDroid.
You can also have a look at sample market app: https://market.android.com/details?id=com.cyrilmottier.android.gdcatalog