I have been trying to figured out what kind of View was the 2 rectangle, I would like to use the same kind of design. I though at first it was a CardView but I think it can be since they are not the same.
Sorry if my question is really basic, I'm still on the learning process.
This view is not one single view, but rather a compound view. To reproduce this type of view, I would recommend, broadly, something like this:
<LinearLayout>
<CardView>
<TextView/> //Name
<TextView/> //Location w/ drawableStart set
<TextView/> //Phone w/ drawableStart set
<TextView/> //link w/ drawableStart set
</CardView>
<CardView>
<TextView/> //Title
<TextView/> //Body
</CardView>
</LinearLayout>
Both of them are CardView only, give a light gray background for the root layout and for card views give elevation and corner radius.
Related
I want to implement the title set at the top like the picture above and please be aware that I am using recyclerview like below. Can anyone have any idea?
<NestedScrollView>
<TextView/>
<RecyclerView/>
<TextView/>
<RecyclerView/>
</NestedScrollView>
To Achieve this, you have to pin your title text view. once the image is scrolled over this, then unpin your title. I suggest you, to use Sectioned RecyclerView Library.
With Nested Recycler View & Item Decorator also you can develop like this.
I'm trying to create an app. I have 4 TextViews, and 4 ImageViews. If I want to put something else at the top of the layout, I have to move all 4 TextViews and all 4 ImageViews down, but I don't want to move them each separately (it takes more time). I`m thinking if there is any possibility to put all of them in a List or something like this, and move all of them only by one xml code.
For example
<TextView/>
<ImageView/>
<TextView/>
<ImageView/>
<TextView/>
<ImageView/>
and move down all of them by one code to make free space for another TextView and ImageView.
Are they all stacked up like that? Try putting them in a LinearLayout, then set attribute layout_marginTop to how much you want them to go down.
i want to put multiple images and scroll down and see them all. I tried to put a ScrollView and inside a ImageView but i dont know if i need to put a layout. I searched tutorials but i didnt found what i needed.
That's clearly not how ScrollViews work. ScrollView is a ViewGroup, so you have to put it outside the view that you want to scroll.
Also, there can only be one view as the direct child of scroll view. So you cannot do this:
<ScrollView>
<ImageView>
<ImageView>
<ImageView>
</ScrollView>
Actually, you should put the images in a LinearLayout, and put the LinearLayout in the scroll view.
<ScrollView>
<LinearLayout>
<ImageView>
<ImageView>
<ImageView>
</LinearLayout>
</ScrollView>
Note: the attributes are omitted because I'm lazy :P
EDIT:
If you want to scroll down, just set the orientation attribute to "vertical".
<ScrollView>
<LinearLayout
android:orientation="vertical"
other attributes.../>
image views here...
</LinearLayout
</ScrollView>
Check out the Android documentation for CardViews http://developer.android.com/training/material/lists-cards.html
You can put an image within each CardView element and a sharebutton below the image. As I previously said, good memory management is a must when working with images and the RecyclerView will work just well.
Cheers
Try this method
<ScrollView>
<LinearLayout>
<ImageView>
<ImageView>
<ImageView>
<ImageView>
<ImageView>
</LinearLayout>
</ScrollView>
I'm pretty new to Android so sorry if this is obvious.
I currently have a few cards that I would like to display extra information when clicked. At the moment they have 6 lines of text and a couple of pictures. I want to display one line of text when the card is pressed and go back when it is pressed again.
The plan I have at the moment is to have 2 identical in size cards and set the visibility of one to gone and when the other is clicked set it to gone and make the other one visible. Is this the best way of doing this? For example, I could use one card and just swap the content.
Thanks for any advice in advance
edit - I'd also like to add some kind of transition - maybe a fade between them so ideally this would be possible too
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<LinearLayout>
<ImageView/>
<TextView/>
<TextView/>
<TextView/>
<ImageView/>
<TextView/>
</LinearLayout>
</android.support.v7.widget.CardView>
Replace with
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<TextView/>
</android.support.v7.widget.CardView>
where the text view is different. I'm basically asking if I should make an entirely new card of just hide all the other text/imageviews and show the new one. I hope I've explained a bit better
I am new to layouts in android and would like to implement a layout like the one shown below however I am a bit confused as to how I should layer my layouts in XML.
I am currently trying a:
<LinearLayout>
<RelativeLayout>
<ImageView>
<TextView>
</RelativeLayout>
<LinearLayout>
<ImageView>
<TextView>
<ImageView>
<TextView>
</LinearLayout>
</LinearLayout>
I don't want to over complicate my layout structure. Would there be a better way to structure this?
Might be best to have a look at this link. As a rule of thumb, don't try and nest layouts too much, i.e. keep them as shallow as possible.
So relative layouts are usually better in this case.
http://developer.android.com/resources/articles/layout-tricks-efficiency.html