【问题标题】:Change size textview in fragment view pager from button in activity从活动中的按钮更改片段视图寻呼机中的文本视图大小
【发布时间】:2015-10-07 17:32:50
【问题描述】:

在我的应用中,我有一个活动。 我的活动

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/Rlayout_top"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#ffffff"
        android:paddingBottom="5dp"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingTop="5dp" >
        <Button
            android:id="@+id/btnUp"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentBottom="true"
            android:layout_marginRight="4dp"
            android:layout_toRightOf="@+id/layout_btn_back"
            android:background="@drawable/custom_btup" />

        <Button
            android:id="@+id/btnDown"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentBottom="true"
            android:layout_toRightOf="@+id/btnUp"
            android:background="@drawable/custom_btdown" />
    </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/Rlayout_top" >
    </android.support.v4.view.ViewPager>

</RelativeLayout>
在我的片段视图寻呼机中,我有一个滚动视图,在滚动视图中,我有一些图片和文字。 现在我想在活动中单击按钮时可以在滚动视图中更改文本视图的大小 我该怎么做?我正在寻找解决方案,发现一些评论说应该使用该界面,但我仍然不明白 请帮我! 谢谢大家

【问题讨论】:

  • 你能给我完整的代码,以便我可以在我的地方尝试一下
  • 可以留下邮箱吗?我发给你

标签: android android-fragments


【解决方案1】:
textView.getLayoutParams.Height = pixels;

【讨论】:

  • 我不太明白
  • 在您的片段中定义您的 textView: TextView textView = (TextView) view.findViewById(R.id.text);然后写上一行
  • 我希望在活动中设置 onclick 侦听器按钮然后片段中的文本更改大小。你的方法能解决吗?
  • 试试这个。 textView = viewPager.getChildAt(position).findViewById(R.id.textView);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多