我想创造像下面这样的东西.

通过使用LinearLayout和TableLayout.但我坚持使用垂直文本.它比旋转后需要的空间更多.
fllowing是XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tv_CONSEQUENCES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="-90"
android:text="CONSEQUENCES"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 假设您有一个普通的TextView,其中写有"Stackoverflow",是否可以将TextView旋转-90°,使底部的S和屏幕顶部的W?当然,我可以把我的文字写成图像,旋转它并以这种方式使用它,但我现在对文本很感兴趣.谢谢.
有没有办法使用XML布局文件显示View,例如TextView?我知道你可以使用活动中的代码来旋转视图,但是有没有办法用布局来做呢?
我有简单的TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="45"
android:text="Simple text" />
Run Code Online (Sandbox Code Playgroud)
在Android 2.2.2上,文本不会旋转到45度.
我看到了不同的主题,但每个人都在做动画.我不想动画.我想要的只是旋转textview.
我有一个EditText,它通常显示与屏幕X轴平行.我想倾斜地显示它(与横轴成45度左右).是否可以在Android中执行此操作.请指导我一个方向,以便我可以尝试.
在pawelzeiba的答案中得到两个链接之后,我继续解决这个问题,但再次陷入困境,所以我又提出了另一个问题.这是链接.
正如Gunnar Karisson所说,在Android 3.0中引入的View类中有一个setRotation()方法,但我无法使用它,因为我的应用程序应该适用于Android 2.1版本.
所以请帮我解决这个问题.
我有几个嵌套的布局,我试图在代码中按需旋转90度.我已经把setRotation的一部分工作得很好,但不幸的是,事情并没有通过轮换来调整.这些元素的宽度设置为match_parent,旋转后它仍然匹配父宽度,而不是它应匹配的父高度.
XML
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="link.basiclifecounter.LifeCounter"
android:background="#CC00CC">
<LinearLayout
android:id="@+id/topPlayers"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical"
android:background="#CC0000">
<RelativeLayout
android:id="@+id/p3"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
**A bunch of stuff in here**
</RelativeLayout>
<RelativeLayout
android:id="@+id/p2"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
**A bunch of stuff in here**
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/bottomPlayer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="#00CC00">
<RelativeLayout
android:id="@+id/p1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
**A bunch of stuff in here**
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
旋转Java代码
view.findViewById(R.id.topPlayers).setRotation(90); //Rotate the entire top box
view.findViewById(R.id.p3).setRotation(180); //Flip one side so both …Run Code Online (Sandbox Code Playgroud) android rotation android-layout android-xml android-layout-weight
我正在为操作栏项添加菜单.菜单将包含每个项目的垂直文本.菜单包含的内容并不重要.我基本上只想创建自己的视图,当我按下操作栏项时会弹出.所以出于这个问题的目的,你可以把我的观点想象成一个大黑盒子.
右边的图像是用Gimp制作的.这是我想要做的,而不是我已经完成的.
为了使用Material Design主题更新旧应用程序,我一直在浏览Android文档中的所有课程以添加应用栏.由于我的垂直文本菜单不适合常见情况,我必须创建一个自定义的Action Provider.但是,该文档未提供自定义操作提供程序的完整示例.我能找到的最好的是Stack Overflow的回答.
我能够做的最好(用黑色视图代表我未来的菜单)如下图所示:
上图中的星号目前有动作提供者.但是,自定义视图会在操作栏中被剪切掉.如何让它浮在一切?此外,我不希望它出现,直到我点击操作栏项目.目前,它只是立即显示.
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// setup toolbar
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
...
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
// User chose the "Settings" item, show the app settings UI... …Run Code Online (Sandbox Code Playgroud)