I'm doing a simple Bluetooth App, to control the window of a car (only for research).
Layout should be two Buttons (Window up and Window down) and a TextView to printed responses on my actions and parameters.
Problem is, that both buttons won't appear in my app :(
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn_window_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/btn_window_up" />
<Button
android:id="@+id/btn_window_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btn_window_up"
android:text="@string/btn_window_down" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btn_window_down"
android:text=""Demo ADK V1.0"" />
</RelativeLayout>
Does anyone has a suggestion how I can solve this?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RxThread rxThread = new RxThread();
MessageStructure demoTxMsg = new MessageStructure();
ReturnCode returnCode = null;
ArrayList<String> deviceList = new ArrayList<String>();
Button btnWindowDown = (Button) findViewById(R.id.btn_window_down);
Button btnWindowUp = (Button) findViewById(R.id.btn_window_up);
tv = new TextView(this);
}
Here the Java-Code
and the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ixxat.adk.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="13" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Demo_ADKActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
try this code. it works for me.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn_window_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_window_up" />
<Button
android:id="@+id/btn_window_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_window_up"
android:text="@string/btn_window_down" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_window_down"
android:text="sample text here" />
</RelativeLayout>
try this ..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn_window_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BTN 1" />
<Button
android:id="@+id/btn_window_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BTN 2" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text view goes over here" />
</LinearLayout>
Or like this ...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_weight="1"
android:id="@+id/btn_window_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BTN 1" />
<Button
android:layout_weight="1"
android:id="@+id/btn_window_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BTN 2" />
</LinearLayout>
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text view goes over here" />
</LinearLayout>
最简单的方法是将LinearLayout
与android:orientation="vertical"
try its
its perfectly show all content of layout..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<Button
android:id="@+id/btn_window_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/btn_window_up" />
<Button
android:id="@+id/btn_window_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btn_window_up"
android:text="@string/btn_window_down" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_window_down"
android:layout_marginTop="10dp"
android:padding="10dp"
android:textColor="@android:color/black"
android:background="@android:color/white"
android:layout_centerHorizontal="true"
android:text=""Demo ADK V1.0"" />
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.