Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android textview是否不喜欢放置在另一个小部件的左侧_Android_Layout_Textview - Fatal编程技术网

Android textview是否不喜欢放置在另一个小部件的左侧

Android textview是否不喜欢放置在另一个小部件的左侧,android,layout,textview,Android,Layout,Textview,这更多的是出于好奇,因为我已经解决了我原来的问题。我希望在屏幕的水平中心有一个按钮,左边有一个文本框,使用相对布局。我很想知道为什么我有以下布局: <Button android:id="@+id/pickTime" android:layout_width="wrap_content" android:layout_below="@id/to_button" android:layout_centerHorizontal="true" androi

这更多的是出于好奇,因为我已经解决了我原来的问题。我希望在屏幕的水平中心有一个按钮,左边有一个文本框,使用相对布局。我很想知道为什么我有以下布局:

    <Button android:id="@+id/pickTime"
    android:layout_width="wrap_content"
    android:layout_below="@id/to_button"
    android:layout_centerHorizontal="true"
    android:layout_height="wrap_content"/>

 <TextView android:id="@+id/timetext"
    android:layout_width="wrap_content"
    android:layout_below="@id/to_button"
    android:layout_toLeftOf="@id/pickTime"
    android:layout_alignTop="@id/pickTime"
    android:layout_height="wrap_content"/>


它确实显示了(尽管左对齐到左边距,而不是右对齐到我最初期望的按钮)。这是所有相关布局的问题(即始终必须按设置的顺序定义小部件),还是与需要从左侧读取的文本有关?

检查此项,它正在工作:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">

<Button android:id="@+id/pickTime"
    android:layout_width="wrap_content"
    android:layout_centerHorizontal="true"
    android:text="Button"
    android:layout_height="wrap_content"/>

 <TextView android:id="@+id/timetext"
    android:layout_width="wrap_content"
    android:layout_toLeftOf="@id/pickTime"
    android:layout_alignTop="@id/pickTime"
    android:layout_height="wrap_content"
    android:text="TextView"/>
</RelativeLayout>


我猜你对android:layout_down=“@id/to_button”有问题,但你没有添加它,我不知道它是什么:(

我认为这与屏幕的宽度有关。当我在HVGA上运行emulator时,我的LayoutToleftof原始代码显示得很好,但当我在我的Hero(320 x 480分辨率)上运行它时,它不会显示。看起来很奇怪,因为它似乎有很多room@Stev_k:粘贴整个xml,以便我们可以更有效地帮助您icient way.@Marcarse它真的太长了,而且我想我现在知道问题是什么了-我把相对布局的布局宽度和布局高度作为包装内容,不像你。不过谢谢你的回答,你让我在测试代码的过程中思考了一下,这样你就可以得到满分了!
  android:layout_alignParentLeft="true"
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">

<Button android:id="@+id/pickTime"
    android:layout_width="wrap_content"
    android:layout_centerHorizontal="true"
    android:text="Button"
    android:layout_height="wrap_content"/>

 <TextView android:id="@+id/timetext"
    android:layout_width="wrap_content"
    android:layout_toLeftOf="@id/pickTime"
    android:layout_alignTop="@id/pickTime"
    android:layout_height="wrap_content"
    android:text="TextView"/>
</RelativeLayout>