不能在另一个 *.axml 文件中包含 *.axml 文件 [英] can't include *.axml file in another *.axml file

查看:23
本文介绍了不能在另一个 *.axml 文件中包含 *.axml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 xamarin android 在另一个 .axml 中包含 .axml 文件的布局,但是,当我使用 它不显示任何东西.什么是等价于 of android in mono android 就像下面的链接:

I want to include a layout of .axml file in another .axml using xamarin android but, when i use <include> it doesn't show any thing. What is the equivalent to <include> of android in mono android just like the link below:

android 重用布局

推荐答案

Xamarin.Android(Android 的 Mono)或原生 Android 的 XML 文件之间没有区别.axml 扩展纯粹是为了触发 VS 和 Xamarin Studio 中的代码完成.Android 并不关心文件的扩展名是什么.

There is no difference between Xamarin.Android (Mono for Android) or native Android's XML files. The axml extension is purely to trigger the code completion in VS and Xamarin Studio. Android does not care what extension the files have.

所以让我展示一个示例,显示 标签:

So let me allow to show a sample showing both the <merge> and <include> tags:

progress_with_text.axml:

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
  <TextView 
    android:text="Loading..."
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:id="@+id/lblLoading" 
    android:layout_marginLeft="180dp"
    android:layout_marginTop="240dp"/>
  <ProgressBar 
    android:id="@+id/progBar"
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"
    android:layout_marginLeft="130dp"
    android:layout_marginTop="230dp"/>
</merge>

ma​​in.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include
        layout="@layout/progress_with_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

这工作得很好!

这篇关于不能在另一个 *.axml 文件中包含 *.axml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆