简体   繁体   English

保证金无效(xml)

[英]Margin not working (xml)

I have a weird problem. 我有一个奇怪的问题。 The margin is not working correctly as it should be. 边距无法正常运行。 It's actually not working all, I dont see any changes when I edit the margin bottom or margin top. 它实际上不能全部正常工作,我在编辑边距底部或边距顶部时看不到任何更改。

I want the copyright to stick to the bottom and I want my button to have some space from the textview. 我希望版权能坚持到底,我希望按钮的文本视图中有一些空间。

My question: how do I let the textview copyright stick to the bottom + how do I create some space between the button and textview? 我的问题:如何让textview版权坚持到底+如何在按钮和textview之间创建一些空间?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" 
android:background="#ffffff"
android:padding="20dp"
>

<TextView 
    android:id="@+id/titel1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="ACT-test"
    android:textSize="20sp" 
    android:textStyle="bold" >
</TextView>

<TextView 
    android:id="@+id/tekst1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="Text."
    android:textSize="15sp" 
    >
</TextView>

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Doe de ACT-test"  
android:background="@drawable/yellow" 
style="@style/ButtonText"    
android:layout_marginTop="50dp" >
</Button>  

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bekijk je ACT-scores"  
android:background="@drawable/blue" 
style="@style/ButtonText"  >
</Button>

<TextView 
    android:id="@+id/copyright"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="Copyright 2002."
    android:textSize="10sp" 
    android:paddingRight="20dp"
    android:paddingLeft="20dp"
    android:layout_marginBottom="10dp" >
</TextView>

 </LinearLayout>

Check this 检查一下

<?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"
    android:background="#ffffff"
    android:orientation="vertical"
    android:padding="20dp" >

    <TextView
        android:id="@+id/titel1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="ACT-test"
        android:textSize="20sp"
        android:textStyle="bold" >
    </TextView>

    <TextView
        android:id="@+id/tekst1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Text."
        android:textSize="15sp" >
    </TextView>

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:text="Doe de ACT-test" >
    </Button>

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Bekijk je ACT-scores" >
    </Button>

    <TextView
        android:id="@+id/copyright"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="bottom|center_horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:text="Copyright 2002."
        android:textSize="10sp" >
    </TextView>

</LinearLayout>

You will need to set the copyright Textview to 您需要将版权Textview设置为

android:layout_alignParentBottom 

This should then allow you to set a margin on the bottom. 然后,这应允许您在底部设置边距。

Which button, and which text view are you trying to put space between? 您要在哪个按钮和哪个文本视图之间放置空格?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM