Google tv not displaying complete layout of my android application - android

I am trying to expand on a basic hello world application for the google tv. I have created a LinearLayout with a EditText and Button within it and put that under a very large 'Hello world' TextView (78sp).
When I launch the application on the google tv box (adb), I get my 'Hello World' but only the very top of the EditText and Button.
Looking at the application within Eclipse Android Layout manager, its all fine and visible.
Any ideas on how to fix this?
I believe I must be missing some configuration element in all of this.
Any help appreciated. Thanks
code, my main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="475dp"
android:gravity="center"
android:text="#string/hello"
android:textSize="78sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="#string/edit_message" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
</LinearLayout>

Probably because your first text view is 475dp high. You can see here that a TV is only 540dp high (remember that an actual pixel and a display independent pixel [dp] are not the same unless the screen is mdpi which no Google TV is)

Related

Scrollbar not visible on android emulator

I am a newbie to android app development, i am using the ADT with eclipse.
I wrapped all the view components in a scrollbar but when i use the emulator preview i cannot see the scrollbar. The target is a 7inch WSVGA (Tablet).
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test_image_date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/Clouds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/test_image"
/>
<TextView
android:id="#+id/imageDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test_image_description"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
No errors have been generated.
Cheers
Ciaran
The scrollview will only be visible if you have enough content that would not fit on the entire screen. Seeing your xml it is possible that you don't have that much of content in the layout
So ran this activity on a Samsung T3 8 inch tablet and the scroll worked fine, couldn't seem to get it on the emulator with a similar simulated device.

Strange Output when Overlapping Views..?

Hi Everyone iam new to android and in my project requirement i need to create two LinearLayouts in same Position and they are animated later in the Java Code,For Testing Purpose initially i inserted image views on those layouts got succesfully after that i removed image views and Inserted EditTexts on the same layout but strange previous image is showing on one linear layout after executing which is not shown in preview
I tested all the options like cleaning the project ,uninstalling from device and reinstaling iam getting the same problem
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Animate Now"/>
<LinearLayout
android:id="#+id/image_list_fragment"
android:layout_width="250dip"
android:layout_below="#+id/button1"
android:layout_height="200dip"
android:background="#FF00FF"
android:layout_centerInParent="true"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Please Enter some text here"
android:singleLine="false"
/>
</LinearLayout>
<LinearLayout
android:layout_width="200dip"
android:layout_height="300dip"
android:orientation="vertical"
android:layout_below="#+id/button1"
android:visibility="visible"
android:background="#32FFFF"
android:layout_centerInParent="true"
android:id="#+id/image_details_fragment"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Please Enter some text here"
android:singleLine="true"
/>
</LinearLayout>
</RelativeLayout>
Here is the output the preview in Eclipse and output in Emulator After running
Please check your backend java file(activity class) once or paste it here. You might be setting an imageview with that background somewhere at runtime.

Textview act like a terminal

Hello I am trying to get text to display like it does in terminal or cmd. And by that I mean a window of text that with each input makes a new line and then displays the bottom line of the TextView, and there would be a set amount of lines always on the screen.
It sounded easy to do, but now that I started I'm not sure how to do it.
I tried putting a TextView in a ScrollView like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100" >
<ScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:id="#+id/tv1"
android:layout_width="wrap_content"
android:minLines="11"
android:maxLines="11"
android:layout_height="wrap_content"/>
</ScrollView>
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="buttonclick"
android:text="Button" />
</LinearLayout>
and then
sss=et1.getText().toString();
tv1.append("\n"+sss);
to add new lines
This all works but I really have no idea how to make the TextView go to the bottom, right now it just cuts off when I hit the max number of lines.
I definitely don't expect anyone to write my program for me. I am here to learn
Thanks for your time!
Call fullScroll(View.FOCUS_DOWN) on the ScrollView after appending the text.

Align dynamic Image and Text in Android

I have a header where I have the text: "Huidige Locatie" and beneath that I have an image of a country flag.
I declared the TextView and ImageView in the layout as follows:
<LinearLayout
android:id="#+id/locatiebalk"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="5sp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/vlaggenlocatie"
android:layout_width="105sp"
android:layout_height="fill_parent"
android:paddingLeft="14sp"
android:orientation="vertical">
<TextView
android:id="#+id/huidiglocatie"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Huidige locatie"
android:textColor="#000000"
android:textSize="12sp"/>
<ImageView
android:id="#+id/flag"
android:layout_width="fill_parent"
android:layout_height="46sp"
android:gravity="left"
android:src="#drawable/nl"/>
</LinearLayout>
(I close the tags correctly later on, just showing the relevant part)
In the Graphical Layout of Eclipse it shows it the right way:
But in the Simulator and on my phone it showes it like this:
What is the best way to do this?
Fixed it.
For the ones wondering: android:scaleType="fitStart" did the job.

Two misplaced lines in UI for Android activity

I have a problem with designing an UI Android activity. There are two blocks of misplaced graphics on the left and right of the activity - they are two lines just bellow the titlebar with 1px height and about 5-10px width. They cause buttons to break at their left and right parts. I cannot figure out what the problem is. I am using Eclipse with Android SDK 0.9.9. The lines appear not only with the emulator but in a HTC Wildfire (Android 2.1). These lines are also visible in a newly created Android project (HelloWorld).
Sorry, but I was not allowed to post images, being too new here :)
Link to the Broken widgets - note the button's left and right sides
XML layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:fitsSystemWindows="true">
<TextView android:layout_height="wrap_content" android:text="This text view should act as header " android:id="#+id/expenseHeaderTxt" android:layout_width="fill_parent" android:paddingLeft="5px" android:paddingRight="5px"/>
<ScrollView android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_marginBottom="50dip" android:id="#+id/expenseScrollView">
<RelativeLayout android:id="#+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars="none" android:paddingLeft="5px" android:paddingRight="5px">
<EditText android:layout_height="wrap_content" android:id="#+id/expenseAmountEdit" android:hint="#string/ExpenseAmountHint" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:selectAllOnFocus="true" android:digits="0123456789" android:inputType="number|numberDecimal" android:maxLines="1"></EditText>
<EditText android:layout_height="wrap_content" android:id="#+id/expenseTypeEdit" android:layout_width="fill_parent" android:layout_toLeftOf="#+id/expenseAmountEdit" android:hint="#string/ExpenseSpendTypeHint" android:inputType="text|textCapSentences" android:maxLines="1"></EditText>
<ToggleButton android:layout_below="#id/expenseTypeEdit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/expenseTypeSignToggle" android:textOn="#string/ExpenseTypeSignPlusToggle" android:textOff="#string/ExpenseTypeSignMinusToggle"></ToggleButton>
<EditText android:layout_below="#id/expenseTypeSignToggle" android:layout_height="wrap_content" android:id="#+id/expenseNoteEdit" android:layout_width="fill_parent" android:hint="#string/ExpenseNoteHint"></EditText>
</RelativeLayout>
</ScrollView>
<RelativeLayout android:layout_marginTop="-50dip" android:gravity="bottom" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingLeft="5px" android:paddingRight="5px">
<Button android:id="#+id/expenseAddBtn" android:layout_width="fill_parent" android:text="A button that should always be at the bottom" android:layout_height="wrap_content"/>
</RelativeLayout>
</LinearLayout>
Funny, I also had the ListView dividers disappearing when scrolling and during the hunt I found the code here:
Disappearing dividers in Spinner drop-down list
It not only fixed the issue with the disappearing separators but also fixed the broken layout.

Categories

Resources