有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何移动我的蓝色条图像以覆盖所有灰色区域?

enter image description here

如图所示,这里的蓝色图像并没有完全移到顶部。我希望能够将这个蓝色的条移动到上面黑色条的边界上,但是小的灰色区域在那里,我不能在图形布局中移动它

编辑:这是XML

<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    xmlns:tools="http://schemas.安卓.com/tools"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    安卓:background="#F3F3F3" >



    <EditText
        安卓:id="@+id/editText1"
        安卓:layout_width="wrap_content"
        安卓:layout_height="wrap_content"
        安卓:layout_alignParentTop="true"
        安卓:layout_centerHorizontal="true"
        安卓:layout_marginTop="124dp"
        安卓:background="@drawable/roundedcorner"
        安卓:ems="10"
        tools:ignore="TextFields" >

        <requestFocus />
    </EditText>

    <ImageView
        安卓:id="@+id/imageView1"
        安卓:layout_width="wrap_content"
        安卓:layout_height="wrap_content"
        安卓:layout_alignParentLeft="true"
        安卓:layout_alignParentTop="true"
        安卓:src="@drawable/bluebars" />

</RelativeLayout>

编辑:我的临时解决方案我通过编程更改了图像的对齐方式

ImageView iv;
iv = (ImageView)findViewById(R.id.imageView1);
iv.getLayoutParams().height = 265;

我称之为临时解决方案,因为在我找到更好的方法(我是RelativeLayout的新手)之前,我会一直使用这个解决方案,而这个解决方案可能会在较大/较小的设备上造成问题。所以不建议这样做,但在我找到更好的方法之前,我会这样做的


共 (2) 个答案

  1. # 1 楼答案

    在你的活动中试试这个

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    正如Aleks G提到的,这应该隐藏标题栏

    确保在setContentView()之前完成此操作

  2. # 2 楼答案

    在你的menifest文件中放入这个应用程序标签

    android:theme="@android:style/Theme.Light.NoTitleBar"
    

    如果您在代码中添加了以下内容,请删除:

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);