Android文本视图随背景旋转
我需要创建一个类似下图的布局。我的问题是如何旋转文本视图并为其添加背景。尝试使用旋转绘图的自定义文本视图。但用这种方法无法正确定位Android文本视图随背景旋转,android,android-layout,Android,Android Layout,我需要创建一个类似下图的布局。我的问题是如何旋转文本视图并为其添加背景。尝试使用旋转绘图的自定义文本视图。但用这种方法无法正确定位 <Button android:id="@+id/dealItemPerc" android:layout_width="150dp" android:layout_height="20dp" android:layout_alignParentLeft="true
<Button
android:id="@+id/dealItemPerc"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:fontFamily="sans-serif-light"
android:background="@drawable/deal_percentage_back"
android:rotation="-45"
android:text="TextView"
android:textColor="@color/app_black"
android:textSize="14sp" />
尝试使用按钮,但也不起作用,因为无法正确定位
像这样创建的。旋转框架布局,其中包含文本视图。我不知道为什么会有人给出负利率
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<me.dushyantha.mywebserviceapp.SquareImageView
android:id="@+id/dealItemImage"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:scaleType="fitXY"
android:src="@drawable/detail_rounded_block" >
</me.dushyantha.mywebserviceapp.SquareImageView>
<FrameLayout
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:rotation="-45"
>
<TextView
android:id="@+id/dealItemPerc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:textSize="14sp"
android:textColor="@color/white"
android:background="@drawable/deal_percentage_back"
/>
</FrameLayout>
</RelativeLayout>
活动\u main.xml
<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"
tools:context="com.example.test1.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="25dip"
android:background="@android:color/black"
android:padding="5dip"
android:rotation="-45"
android:text="Hello World"
android:textColor="@android:color/white" />
</RelativeLayout>
Nothing使用java代码执行操作
构建并运行项目
完成你到底想要什么?