Android layout organization - android

I have some general question about layouts in my application I ma trying to make. I have attached a screenshot of how this is suppose to look like. There are 2 headers at the top (search bar with back button), another list of properties (Crag, Grade...). Then we have vertical scrollable table layout.
This is little bit of beginner question, but what layouts would I use to create such page, for example something like this (of course this would need to go in more details to handle all information, but as in rough layout?
<Relative layout>
<Frame layout> search bar </Frame layout>
<Frame layout> list of properties (Crag, Grade...) </Frame layout>
<Table layout> vertical scrollable </Table layout>
</Relative layout>

You can do something like below
<LinearLayout orientation=vertical>
<Toolbar> search bar </Toolbar>
<LinearLayout orientation=horizontal> list of properties (Crag, Grade...) </LinearLayout>
<RecyclerView>
</LinearLayout>

Related

Android Paralloid and ImageView onClick

I'm currently trying to implement Paralloid by chrisjenx for Android. It uses a FrameLayout that hosts two different layouts that take up the entire screen size. I need to perform an event during an ImageView's onClick(). The ImageView is located in the first layout.
For example:
<Frame Layout>
<Relative Layout>
<ImageView/>
<!-- Need this guys onclick, nothing outputted though. -->
</Relative Layout>
<chris.jenx.paralloid/>
</Frame Layout>
I've even gone as far as making sure Relative Layout and Image View both have clickable="true" and focusable="true". No Luck.
Have you tried setting the Image clickable property to true?
android:clickable="true";

Custom Shape in android

I would like to make a custom shape like in the image, but i have no idea how to start, could some body help please
i think you have to deal with images.
you can create a seperate xml for the "head box" like this
<linear layout>
<text view background="dark-grey" text = "o nuts"/>
<image view src="blue line" />
<linear layout>
<image view src="donut" />
<linear layout>
<text view text="price" />
<text view text="date" />
</linear layout>
<image view src="box_border_shadow_lines" />
</lienar layout>
</linear layout>
and somethink similar for the articles...
attention this is no valid xml :) just some hints
Documentation is not enough?
The part you shown on the top in image is Action Bar u can start learning how to make an action bar. i have one example of Action Bar.
Which one? the shape on the bottom of the image with the "Redeem" button?

Android layout load sub layouts

I want to make my xml layout more modular because this one is going to be pretty intricate!
I want some pieces to be in their own xml files. How would I reference them properly in the main XML file.
for instance
Lets say I have a
<relative layout>
<linear layout>
<relative layout>
<frame layout>
<relative layout>
<linear layout>
but the <frame layout> has a very complex child, with columns containing buttons and scrollviews which contain listviews.
I would like to develop the frame layout in its own XML and then merely reference that xml document within my main one
what would the syntax for that look like? is it solely related to the ID that assign to <frame layout> within my main XML?
The article Layout Tricks: Merging Layouts describes the <merge> and the <include> tag for layout xml files.
With <include> you can reference an other layout and <merge> can help to make your view hierarchy flatter.

Android: adding components to RelativeLayout

in My screen, i want to have Hearder(specifically image) on top, and List, and at bottom i want to have small imagebuttons (like youtube,facebook).
I'm using RelativeLayout.. first two are displaying correctly, last one not display at all on the screen, can anyone help here.
my layout file looks like this
<RelativeLayout>
<image></image>
<ListView></ListView>
<RelativeLayout>
<ImageButton></ImageButton>
</RelativeLayout>
</RelativeLayout>
In a RelativeLayout it matters in which order you add the child views (since the latter can be bound to the ones added previously).
I think this is the problem in your layout, you have a fill_parent/match_parent high view already inside (the ListView), and there is no room for the footer.
You should change the order of your views inside the RelativeLayout:
first you should add the header view
(and bind it to the top: android:align_parent_top="true"), then
the footer with buttons (and bind it
to the bottom: android:align_parent_bottom="true"), and
the ListView which should fill up
the empty space will go in as the
thirds view, with
android:layout_below="header_view"
and
adroid:layout_above="footer_view"`
Your layout would then look like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout>
<image android:id="#+id/header"
android:layout_alignParentTop="true"></image>
<RelativeLayout android:id="#+id/footer"
android:layout_alignParentBottom="true">
<ImageButton></ImageButton>
</RelativeLayout>
<ListView
android:layout_below="#id/header"
android:layout_above="#id/footer"></ListView>
</RelativeLayout>

ScrollView not displaying some UI elements

I'm developing an application with executes searches via an API on a web server. My search page displays well in portait mode but is too big for landscape mode so I've decided to simply contain all UI elements in a ScrollView by customising the XML in layout-land folder. The problem is, the buttons on the bottom of my form are not being shown in landscape ScrollView. I don't use ScrollView in portrait so maybe that's the problem? The layout XML is like this:
<LinearLayout>
<ScrollView>
<LinearLayout>
<TableLayout>
<!-- stuff here is being shown (table with TextViews and EditTexts -->
</TableLayout>
<LinearLayout>
<!-- stuff here is not being shown (3 Buttons) -->
</LinearLayout>
</LinearLayout>
</ScrollView>
Most likely you forgot to set android:orientation="vertical" to your LinearLayout (direct child of ScrollView).

Categories

Resources