如何在线性布局内的ListView上方放置一个TextView

时间:2018-06-28 11:07:58

标签: android android-linearlayout

我试图将TextView放置在线性布局内的ListView上方,但进展并不很快。.我尝试将电视放置在自己的布局中,并尝试在页面顶部添加边距LV,但似乎没有任何作用。电视似乎具有某种不可移动的衬垫。请在下面查看屏幕截图和.XML

设计视图布局

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:id="@+id/setting_frag"
    android:baselineAligned="false">


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="hello"/>

    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:background="?attr/colorBackgroundFloating"
        android:descendantFocusability="blocksDescendants" />


    <RelativeLayout
        android:id="@+id/setting_dialogue"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
        <ViewStub
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/device_info_stub"
            android:inflatedId="@+id/device_info_stub_inflated_id"
            android:layout="@layout/device_info"
            />
        <ViewStub
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/health_check_stub"
            android:inflatedId="@+id/health_check_stub_inflated_id"
            android:layout="@layout/health_checks"
            />
        <ViewStub
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/system_config_stub"
            android:inflatedId="@+id/system_config_stub_inflated_id"
            android:layout="@layout/system_configuration"
            />
        <ViewStub
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/database_stats_stub"
            android:inflatedId="@+id/database_stats_stub_inflated_id"
            android:layout="@layout/database_stats"
            />
        <ViewStub
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/check_update_stub"
            android:inflatedId="@+id/device_info_stub_inflated_id"
            android:layout="@layout/device_info"
            />

    </RelativeLayout>

Screenshot

New screenshot

2 个答案:

答案 0 :(得分:1)

android:orientation="horizontal"更改为android:orientation="vertical"


您希望列表和相对存根并排使用以下代码。

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/setting_frag"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:baselineAligned="false"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:baselineAligned="false"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#F00"
            android:textColor="@color/white"
            android:text="hello" />


        <ListView
            android:id="@+id/lv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#0F0"
            android:descendantFocusability="blocksDescendants" />
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/setting_dialogue"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00F"
        android:layout_weight="1">

        <ViewStub
            android:id="@+id/device_info_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/device_info_stub_inflated_id"
            android:layout="@layout/activity_burst_assignees" />

        <ViewStub
            android:id="@+id/health_check_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/health_check_stub_inflated_id"
            android:layout="@layout/activity_burst_assignees" />

        <ViewStub
            android:id="@+id/system_config_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/system_config_stub_inflated_id"
            android:layout="@layout/activity_burst_assignees" />

        <ViewStub
            android:id="@+id/database_stats_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/database_stats_stub_inflated_id"
            android:layout="@layout/activity_burst_assignees" />

        <ViewStub
            android:id="@+id/check_update_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/device_info_stub_inflated_id"
            android:layout="@layout/activity_burst_assignees" />

    </RelativeLayout>


</LinearLayout>

代码的输出如下所示

答案 1 :(得分:0)

 public static void main(String[] args) throws Exception {

 String inputfilepath = "C:\\Users\\saranyac\\QUERIES\\Estimation\\PPT-PSR\\PSR_Dev0ps\\PSRAutomationTemplate.pptx";

 PresentationMLPackage presentationMLPackage =           (PresentationMLPackage)OpcPackage.load(new java.io.File(inputfilepath));

     MainPresentationPart pp = presentationMLPackage.getMainPresentationPart();

      SlidePart slidePart = presentationMLPackage.getMainPresentationPart().getSlide(0);

        SlideLayoutPart layoutPart = slidePart.getSlideLayoutPart();

        System.out.println("SlidePart Name:::::"+slidePart.getPartName().getName());

        String layoutName = layoutPart.getJaxbElement().getCSld().getName(); 

        System.out.println("layout: " + layoutPart.getPartName().getName() + " with cSld/@name='" + layoutName + "'");

        System.out.println("Master: " + layoutPart.getSlideMasterPart().getPartName().getName());

        System.out.println("layoutPart.getContents()::::::::s: " + layoutPart.getContents());

        //layoutPart.setContents(   (SldLayout)XmlUtils.unmarshalString(SAMPLE_PICTURE, Context.jcPML));


        // Add image part
        File file = new File("C:\\Users\\saranyac\\PPT-PSR\\PSR_Dev0ps\\ppt\\media\\image10.png" );
        BinaryPartAbstractImage imagePart 
            = BinaryPartAbstractImage.createImagePart(presentationMLPackage, slidePart, file);

                   Relationship rel = pp.getRelationshipsPart().getRelationshipByID("rId8");    
     System.out.println("Relationship:::::::s: " +imagePart.getSourceRelationship().getId());

      // pp.removeSlide(rel);
       java.util.HashMap<String, String>mappings = new java.util.HashMap<String, String>();

        mappings.put("rId8", imagePart.getSourceRelationship().getId());

         String outputfilepath = "C:\\Work\\24Jan2018_CheckOut\\PPT-TRAILS\\Success.pptx";
        //presentationMLPackage.save(new java.io.File(outputfilepath));

        SaveToZipFile saver = new SaveToZipFile(presentationMLPackage);
        saver.save(outputfilepath);

        System.out.println("\n\n done .. saved " + outputfilepath);

    }   

我已经进行了更改。这将为您工作。