mrn*_*ody 6 android android-animation
我已经看了几个阅读更多按钮问题,但我没有得到一种我看起来更多的解决方案.我想只显示布局的某些部分,并且只有当用户按下"阅读更多"按钮时才会显示布局的其余部分,并带有下拉动画.这种东西:

我无法为您提供您想要的确切代码,但我可以通过提供满足您要求的示例代码来帮助您,
\n\n这里我只描述更多/更少按钮功能是如何工作的。\n首先在您的activity_main.xml 文件中粘贴以下代码。
\n\n<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:tools="http://schemas.android.com/tools"\n android:layout_width="match_parent"\n android:layout_height="match_parent" >\n\n <RelativeLayout\n android:layout_width="match_parent"\n android:layout_height="wrap_content" >\n\n <TextView\n android:id="@+id/description_text"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:maxLines="5"\n android:text="@string/desc_content" />\n\n <ImageButton\n android:id="@+id/show"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_alignParentRight="true"\n android:layout_below="@+id/description_text"\n android:background="@drawable/arrow_down"\n android:clickable="true" />\n\n <View\n android:id="@+id/view1"\n android:layout_width="wrap_content"\n android:layout_height="2dp"\n android:layout_below="@+id/description_text"\n android:layout_marginTop="5dp"\n android:layout_toLeftOf="@+id/show"\n android:background="#000" />\n\n <ImageButton\n android:id="@+id/hide"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_alignParentRight="true"\n android:layout_below="@+id/description_text"\n android:background="@drawable/arrow_up"\n android:clickable="true"\n android:visibility="invisible" />\n </RelativeLayout>\n\n</ScrollView>\nRun Code Online (Sandbox Code Playgroud)\n\nMainActivity.java
\n\npackage com.example.expand.textview;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.view.View.OnClickListener;\nimport android.widget.ImageButton;\nimport android.widget.TextView;\n\npublic class MainActivity extends Activity {\n TextView descText;\n ImageButton show, hide;\n\n @Override\n public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n descText = (TextView) findViewById(R.id.description_text);\n show = (ImageButton) findViewById(R.id.show);\n show.setOnClickListener(new OnClickListener() {\n\n @Override\n public void onClick(View v) {\n System.out.println("Show button");\n show.setVisibility(View.INVISIBLE);\n hide.setVisibility(View.VISIBLE);\n descText.setMaxLines(Integer.MAX_VALUE);\n\n }\n });\n hide = (ImageButton) findViewById(R.id.hide);\n hide.setOnClickListener(new OnClickListener() {\n\n @Override\n public void onClick(View v) {\n System.out.println("Hide button");\n hide.setVisibility(View.INVISIBLE);\n show.setVisibility(View.VISIBLE);\n descText.setMaxLines(5);\n\n }\n });\n\n }\n\n}\nRun Code Online (Sandbox Code Playgroud)\n\n最后更改您的 string.xml 文件\nstring.xml
\n\n<resources>\n\n <string name="app_name">Expand TextView</string>\n <string name="hello_world">Hello world!</string>\n <string name="menu_settings">Settings</string>\n <string name="title_activity_main">MainActivity</string>\n <string name="desc_content"> Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It\\\'s the largest installed base of any mobile platform and growing fast\xe2\x80\x94every day another million users power up their Android devices for the first time and start looking for apps, games, and other digital content.\n\nAndroid gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.\n</string>\n\n</resources>\nRun Code Online (Sandbox Code Playgroud)\n\n并运行你的项目它会给你以下输出。
\n\n\n| 归档时间: |
|
| 查看次数: |
7482 次 |
| 最近记录: |