【问题标题】:How to adding TextView in PageCurl?如何在 PageCurl 中添加 TextView?
【发布时间】:2012-08-02 02:53:30
【问题描述】:

我是 android 新手,我在这个链接 http://code.google.com/p/android-page-curl/ 中发现了这个很棒的 android 页面卷曲。 我的问题是,如何添加 TextView? 我已经尝试过了,但是当我尝试时它总是强制关闭。 这是我在布局 xml 中的代码。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <cv.tarie.pagecurl.PageCurlView
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:id="@+id/dcgpagecurlPageCurlView1"/>

    <LinearLayout android:id="@+id/textlayout"
        android:layout_width="fill_parent" android:layout_height="100dp"
        android:layout_alignParentBottom="true" android:gravity="center"
        android:background="#55000000" android:padding="5dp">

        <TextView android:id="@+id/dialog" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:textSize="18dp"
            android:textColor="#FFFFFF" />

    </LinearLayout>
</RelativeLayout>

我在 PageCurlView 中添加了这段代码。

TextView tv = (TextView) findViewById(R.id.dialog);
tv.setText("Hello!");

我的代码有问题吗??

谢谢..

【问题讨论】:

    标签: android textview android-relativelayout page-curl


    【解决方案1】:

    您应该提供更多信息:您在哪里添加了该代码? logcat 的输出是什么,...

    无论如何,从查看您的 XML 开始,对您自己提出一个简单的问题: 为什么 PageCurlView 应该能够找到 TextView 元素,它不是它的子元素?

    你有:

    • 相对布局
      • PageCurlView
      • 线性布局
        • 文本视图

    TextView 是 RelativeLayout 和 LinearLayout 的唯一子级。 在 PageCurlView 中找不到 TextView。 FindViewById() 仅下降到 ViewGroups 子项,而不是父项。

    我只是在想,你的问题可能是完全错误的。您是否尝试询问“如何使 PageCurl 在 TextViews 之间切换,而不仅仅是图像?”。答案是:阅读文档,或者只是主网站的第一页。这不可能。它只能在图像之间切换。

    【讨论】:

    • 好的..这是我的错,因为我是android新手.. :D我只是尝试制作具有透明背景的文本.. :)
    • @user1561886:那么,你又问了什么?它甚至与 PageCurlView 有关吗? ;)
    • 嗯..是的,我错了。我只需要制作带有黑色透明背景的TextView,并且我希望在翻转页面时文本会发生变化。我现在需要做研究,然后再问这个问题。 -.-”顺便说一句,谢谢你回答我的问题。:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-27
    相关资源
    最近更新 更多