I developing an Android App in Eclipse and i'm using framelayout as a container to my fragment... and the fragment doesn't showing full text... half of the text is hiding...
Please help me out...!!!
Thanks in advance...
activty_main.xml `
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"/>
</ScrollView>
`
fragment_about.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About Us"
android:textColor="#F44336"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="30dp"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" Our vision is to interrelate the old and present students of college with each other and to develop a constant interaction among them.This also serves as a good opportunity to get the required career guidance to reach their future endeavours."
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="9dp"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" We provide e-library to our students which compraises many number of e-books, projects and all fundamentals of electronics"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="9dp"
/>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" We automized our students internal/external marks system so, every student can log on to his account and get his/her result at any time after the results are out"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
original fragment is Original
but the output coming is output
the remaining part is missing
Thanks in advance
Please try this once. Keep the activity_main.xml as it is. In case of the fragment_about.xml put the root view as a ScrollView and just add a view at the below i.e.
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About Us"
android:textColor="#F44336"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="30dp"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" Our vision is to interrelate the old and present students of college with each other and to develop a constant interaction among them.This also serves as a good opportunity to get the required career guidance to reach their future endeavours."
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="9dp"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" We provide e-library to our students which compraises many number of e-books, projects and all fundamentals of electronics"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="9dp"
/>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196F3"
android:text=" We automized our students internal/external marks system so, every student can log on to his account and get his/her result at any time after the results are out"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:layout_width="match_parent"
android:layout_height="25dp"/>
</LinearLayout>
</ScrollView>
Hope it will help.
Try like this
main_activity.xml()
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<FrameLayout
android:id="#+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"/>
</ScrollView>
Related
I am currently having an issue with a mobile app I am developing. The idea behind it being it displays the value of various variables from a passed object. As I have needed to add more and more objects to the layout xml file in order to display everything, the preview has since stopped displaying any objects besides the action bar and trying to start the activity using this layout crashes the app.
I have a feeling this may be due to the layout being larger than the virtual device screen, though there could be another cause i'm totally unaware of. Any help in this matter would be appreciated. This activity currently uses the Relative layout, would it resolve the issue to wrap the Relative layout in a Scrollview to make the activity scrollable?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Name"
android:id="#+id/RequestNameTextView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/RequestNameDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestNameTextView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Student ID"
android:id="#+id/RequestStudentIDTextView"
android:layout_below="#+id/RequestNameDisplay"/>
<TextView
android:id="#+id/RequestStudentIDDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestStudentIDTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/RequestLocationTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestStudentIDDisplay"
android:text="Location"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="#+id/RequestLocationDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestLocationTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/RequestProblemTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestLocationDisplay"
android:text="Problem Description"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="#+id/RequestProblemDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestProblemTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/RequestStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestProblemDisplay"
android:text="Current Status"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RequestStatusDisplay"
android:layout_below="#+id/RequestStatusTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/RequestAssignmentTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestStatusDropDown"
android:text="Assigned To"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RequestAssignmentDisplay"
android:layout_below="#+id/RequestAssignmentTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/RequestStatusUpdateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestAssignmentDisplay"
android:text="Update Status to:"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RequestStatusDropDown"
android:layout_below="#+id/RequestStatusUpdateTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/RequestAssignmentUpdateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RequestStatusDropDown"
android:text="Assign Request To:"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RequestAssignmentDropDown"
android:layout_below="#+id/RequestAssignmentUpdateTextView"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<Button
android:id="#+id/RequestSaveChangesButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Save Changes" />
</RelativeLayout>
It is because your Relative Layout having Circular dependencies. From RequestAssignmentTextView to RequestStatusDropDown, your are having a circular dependency. Just change your 'below' element of RequestAssignmentTextView to avoid this error.
Below is my layout File. But I'm not able to align the Textview (#id/role) and Imageview(#id/flag) left and right of each other. Text appears to be over the ImageView.
Below is my layout File
<?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:orientation="horizontal"
>
<ImageView
android:id="#+id/flag"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/bas" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/name"
android:text="Xyz Nepal"
android:padding="5dp"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/red"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:layout_toLeftOf="#id/flag"
android:padding="5dp"
android:text=" Nepali physicist specializing in cosmology. Having worked in the Central Department of Physics for 34 years"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#027e76"
android:textStyle="bold" />
<TextView
android:layout_marginTop="15dp"
android:id="#+id/desc"
android:layout_margin="5dp"
android:padding="5dp"
android:text="Binil Aryal is the Professor and newly appointed Head of the Department at Central Department of Physics, Tribhuvan University, Kathmandu, Nepal.He was Born in 1969-09-28 in Saptari District of Eastern Nepal.
He is one of the actively working astrophysicist of Nepal. He has been working in the field of Galaxy orientation and Evolution. He has served as a judge of International Astronomy Olympiad. He is the country representative of BCVSPIN school.
He was awarded by 'Mahendra Bidhya Bhushan ka' by the late king Birendra Shah for securing highest score in the M.Sc. Examination. He received 'Third World Academy Award (TWAS)' for his Ph.D. work."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:padding="5dp"
android:layout_margin="5dp"
android:id="#+id/email"
android:text="xyz#gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#0d38f7"/>
</LinearLayout>
</RelativeLayout>
This is how it appears
This is what i want
Thanks in Advance. I did use The Linearlayou and Relativelayout to position item but I did a terrible job and also I would like to stretch the textview irrespective of Screen size but don't overlap the image and alwasy stay left of Image.
Try this code see if its what you want.
<?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:orientation="horizontal">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:padding="5dp"
android:text="#string/xyz"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<ImageView
android:id="#+id/flag"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:src="#drawable/launcher"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:padding="5dp"
android:layout_below="#id/name"
android:layout_toLeftOf="#id/flag"
android:text="#string/role
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#027e76"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#id/role"
android:padding="10dp">
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:padding="5dp"
android:text="#string/desc"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:padding="5dp"
android:text="xyz#gmail.com"
android:textColor="#0d38f7" />
</LinearLayout>
Try the following:
<?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:orientation="horizontal">
<ImageView
android:id="#+id/flag"
android:layout_margin="5dp"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_alignParentRight="true"
android:src="#drawable/capture" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:id="#+id/ll"
android:layout_toStartOf="#id/flag"
android:orientation="vertical">
<TextView
android:id="#+id/name"
android:text="Xyz Nepal"
android:padding="5dp"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/holo_red_light"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:layout_toLeftOf="#id/flag"
android:padding="5dp"
android:text=" Nepali physicist specializing in cosmology. Having worked in the Central Department of Physics for 34 years"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#027e76"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:layout_marginTop="15dp"
android:id="#+id/desc"
android:layout_margin="5dp"
android:padding="15dp"
android:text="Binil Aryal is the Professor and newly appointed Head of the Department at Central Department of Physics, Tribhuvan University, Kathmandu, Nepal.He was Born in 1969-09-28 in Saptari District of Eastern Nepal.
He is one of the actively working astrophysicist of Nepal. He has been working in the field of Galaxy orientation and Evolution. He has served as a judge of International Astronomy Olympiad. He is the country representative of BCVSPIN school.
He was awarded by 'Mahendra Bidhya Bhushan ka' by the late king Birendra Shah for securing highest score in the M.Sc. Examination. He received 'Third World Academy Award (TWAS)' for his Ph.D. work."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/ll"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:padding="15dp"
android:layout_margin="5dp"
android:id="#+id/email"
android:text="xyz#gmail.com"
android:layout_below="#id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#0d38f7"/>
</RelativeLayout>
Output:
I want to suggest to place text view with id as name and role should be inside separate LinearLayout and adjust to meet required UI.
<?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:orientation="horizontal">
<ImageView
android:id="#+id/flag"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/bas" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_toLeftOf="#+id/flag"
android:orientation="vertical">
<TextView
android:id="#+id/name"
android:text="Xyz Nepal"
android:padding="5dp"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/red"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:layout_toLeftOf="#id/flag"
android:padding="5dp"
android:text=" Nepali physicist specializing in cosmology. Having worked in the Central Department of Physics for 34 years"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#027e76"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout2"
android:layout_below="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:layout_marginTop="15dp"
android:id="#+id/desc"
android:layout_margin="5dp"
android:padding="5dp"
android:text="Binil Aryal is the Professor and newly appointed Head of the Department at Central Department of Physics, Tribhuvan University, Kathmandu, Nepal.He was Born in 1969-09-28 in Saptari District of Eastern Nepal.
He is one of the actively working astrophysicist of Nepal. He has been working in the field of Galaxy orientation and Evolution. He has served as a judge of International Astronomy Olympiad. He is the country representative of BCVSPIN school.
He was awarded by 'Mahendra Bidhya Bhushan ka' by the late king Birendra Shah for securing highest score in the M.Sc. Examination. He received 'Third World Academy Award (TWAS)' for his Ph.D. work."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:padding="5dp"
android:layout_margin="5dp"
android:id="#+id/email"
android:text="xyz#gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#0d38f7"/>
</LinearLayout>
</RelativeLayout>
Use a vertical linear layout (by default vertical) and put the image view and text view (first text view example-xyz nepal) in it . And rest in linear horizontal layout for other text view(example-the green color text and others ) it will definitely solve your problem
Others too have this issue, but mine is unique (I think) in that this error only occurs when I open the keyboard within the app like this. It does not happen when the keyboard is not opened.
Again, the error is:
W/Ads: Not enough space to show ad. Needs 320x50 dp, but only has 384x0 dp.
Here is the XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<EditText
android:id="#+id/input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your Number"
android:textAlignment="center"
android:layout_gravity="center"
android:inputType="text"
android:ems="25"
android:textColor="#color/colorPrimary"
android:textSize="20sp"
android:maxLength="31"
android:layout_marginTop="30dp"
android:layout_marginBottom="45dp"/>
<TextView
android:id="#+id/from"
android:text="#string/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/colorPrimary"
android:textSize="16sp" />
<Spinner
android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:entries="#array/spinner_entries1"
android:background="#null"
android:layout_marginBottom="25dp"/>
<TextView
android:id="#+id/to"
android:text="#string/to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/colorPrimary"
android:textSize="16sp" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:cursorVisible="false"
android:entries="#array/spinner_entries2"
android:layout_marginBottom="20dp"/>
<EditText
android:id="#+id/output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_gravity="center"
android:inputType="text"
android:ems="25"
android:textColor="#color/colorPrimary"
android:textSize="20sp"
android:maxLength="31"
android:layout_marginBottom="30dp" />
<Button
android:id="#+id/button"
android:text="#string/button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:textColor="#FFFFFF"
android:onClick="convert"
android:layout_gravity="center" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
ads:adSize="BANNER"
ads:adUnitId="#string/admob_id"
android:layout_marginTop="50dp"
/>
</LinearLayout>
How do I go about fixing this?
EDIT: I wouldn't bother fixing this, because the ad returns back to normal when the keyboard goes away, BUT Views flicker when the keyboard 'touches' a view.
Fixed by adding
android:windowSoftInputMode="adjustPan"
to AndroidManifest.xml under <activity</>
Answer found here
I was tasked to create a simple book searching app for Android as an internship project. I'm almost done with this, but I'm very bad at doing layouts. The published date and description will ALWAYS fly to the left and out of the screen if the ISBN number is 10 digits long, but it's perfectly fine when its just 13 digits long. Just for reference, I'm using the google books API. This would be much clearer if I could post pictures, but my rep is too low for that.
Here's my code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/img_cover"
android:layout_width="180dp"
android:layout_height="170dp"
android:src="#drawable/img_books_large"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/tvTitle"
android:text="Title"
android:layout_marginTop="20dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/img_cover"
android:layout_toEndOf="#+id/img_cover" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Author"
android:id="#+id/tvAuthor"
android:layout_marginTop="25dp"
android:layout_below="#+id/tvTitle"
android:layout_toRightOf="#+id/img_cover"
android:layout_toEndOf="#+id/img_cover" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/img_cover"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ISBN"
android:id="#+id/tvISBN"
android:layout_below="#+id/img_cover"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Publish Date"
android:id="#+id/tvPublishYear"
android:layout_below="#+id/tvISBN"
android:layout_marginTop="40dp"
android:layout_marginLeft="-220dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvDescription"
android:layout_marginTop="80dp"
android:layout_below="#+id/tvPublishYear"
android:layout_marginLeft="-270dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Description"
/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Thanks in advance
Nvm fixed it.
Just had to add
android:orientation="vertical"
to LinearLayout
Hello stackoverflow members. i am trying to achieve this:http://imgur.com/dqwOAOf
But for some reason the two texts cant take these positions like this http://imgur.com/lyYg8Ei
Could anyone explain what i am doing wrong?
and please forgive my artistic talents.
i have added the whole xml file.
The idea is that the two textviews timer and typegekookt are displayed in the center of backgroundtypegekookt evenly spaced out.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="#+id/eggContainer"
android:layout_height="wrap_content"
android:padding="15dp">
<ImageView android:id="#+id/eggtimerimage"
android:src="#drawable/eiwit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_vertical"
/>
<ImageView android:id="#+id/backgroundtypegekookt"
android:src="#drawable/timerwijzer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
/>
<TextView
android:id="#+id/typegekookt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="zacht"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_alignTop="#+id/divider2"
android:layout_centerHorizontal="true"/>
<TextView
android:id="#+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10:00"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/divider2"
/>
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="#+id/divider1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/eggtimerimage"
android:layout_marginBottom="-30dp"
/>
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="#+id/divider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignLeft="#+id/backgroundtypegekookt"
android:layout_alignStart="#+id/backgroundtypegekookt"
android:layout_alignRight="#+id/backgroundtypegekookt"
android:layout_alignEnd="#+id/backgroundtypegekookt" />
</RelativeLayout>
Instead of using the ImageView android:id="#+id/backgroundtypegekookt", use a RelativeLayout (or a LinearLayout) with that background (android:background="#drawable/timerwijzer"), and put your TextViews in it
This is what I mean:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="#+id/eggContainer"
android:layout_height="wrap_content"
android:padding="15dp"
>
<ImageView
android:id="#+id/eggtimerimage"
android:src="#drawable/eiwit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_vertical"
/>
<LinearLayout
android:id="#+id/backgroundtypegekookt"
android:background="#drawable/timerwijzer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:orientation="vertical"
>
<TextView
android:id="#+id/typegekookt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="zacht"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="#+id/timer"
android:below="#id/typegekookt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="10:00"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_centerHorizontal="true"
/>
</LinearLayout>
<!-- You can use 2 Views instead of 2 TextViews, more efficiently -->
<!-- Anyway, in your screenshots I only see 1 - I guess you'll have to fix that -->
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="#+id/divider1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-30dp"
/>
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="#+id/divider2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignLeft="#id/backgroundtypegekookt"
android:layout_alignStart="#id/backgroundtypegekookt"
android:layout_alignRight="#id/backgroundtypegekookt"
android:layout_alignEnd="#id/backgroundtypegekookt"
/>
</RelativeLayout>
I also fixed the deprecated fill_parent to match_parent and #+id (anticipated reference) to #id (reference), where needed.
Also see my comments in the layout avout the 2 last views.